ReactNative2 [React Native] 2 Hook class로 작성할 시 getter/setter사용으로 복잡해질 수 있으므로 hook을 사용함으로 간소하게 작성 // class형태 class App extends React.Component{ constructor(props: any){ super(props) // state는 기본 지원되는 변수 this.state = { count: 0 } } // render: 기본 지원되는 함수(xml코드를 return해주는 함수) render() { return( You clicked{this.state.count} times this.setState({ count: this.state.count + 1 }) }/> ) } } export default App // hook const App = () .. 2022. 3. 4. [React Native] App.tsx 작성 export default function App(){ // 상수(변경할 수 없는 수) const str:String = "Hello World" // return에 두개의 를 쓰기 위해선 루트태그 사용 return( Hello TSX World { str } ) } export default function App(){ const name = '홍길동' return( Hello Tsx {name} ) } 조건문 export default function App(){ const isLoading = true // 1. if문을 이용 if(isLoading){// isLoading == true return( Loading... ) }else{// isLoading == false re.. 2022. 3. 4. 이전 1 다음