728x90
반응형

React Native 96

스크랩 ) React Native 부모에서 자식 함수 호출하기

// App.js import React, { useRef } from "react"; import Child from "./Child"; export default function App() { const childRef = useRef(); return ( { childRef.current.showAlert(); }} > 버튼 눌러 ); } // Child.js import React, { forwardRef, useImperativeHandle } from "react"; const Child = forwardRef((props, ref) => { useImperativeHandle(ref, () => ({ showAlert() { alert("hi"); } })); return 자식임; }); e..

React Native 2021.11.03

React Native - TypeScrip 로 시작하기

1 ) 프로젝트 생성 npx react-native init MyApp --template react-native-template-typescript 2) 필요 모듈 추가 npm install -D typescript @types/jest @types/react @types/react-native @types/react-test-renderer 3) tsconfig.json 파일 생성 및 내용 추가 { "compilerOptions": { "allowJs": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "isolatedModules": true, "jsx": "react", "lib": ["es6"], "moduleResolu..

React Native 2021.05.22

앱 상태 체크

React Native 앱 상태 체크 AppState 는 앱이 동작하거나 백그라운드에 있을 때, 상태가 변경 되는것을 알려준다. AppState는 의도와 적절한 행동을 결정하는데 종종 사용되어진다, 푸시 알람을 사용할 때. App States active: foreground에서 동작 background: background에서 동작 [ios] inactive Basic Usage AppState.currentState를 통해서 앱 상태를 알 수 있다. 브릿지를 통해서 추출 되기 전엔 currentState가 null이 될것이다. import React, { Component } from 'react'; import { AppState, Text } from 'react-native'; class App..

React Native 2020.12.02
728x90
반응형