npx react-native init ch02_2 --template react-native-template-typescript
TypeScript React Native 프로젝트를 생성한다.
import React from 'react'
import { SafeAreaView, Text } from 'react-native'
export default function App(){
return(
<SafeAreaView>
<Text>Hello JSX World!</Text>
</SafeAreaView>
)
}
<Text>
{ /* JavaScript code */ }
</Text>
const hello = 'Hello World'
<Text>{ hello }</Text>
const virtualDOM = <SafeAreaView><Text>Hello JSX World!</Text></SafeAreaView>
export default function App(){
return <SafeAreaView><Text>Hello JSX World!</Text></SafeAreaView>
}
import React from 'react';
import {SafeAreaView, Text} from 'react-native';
export default function App(){
const isLoading = true
if(isLoading){
return(
<SafeAreaView>
{isLoading && <Text>Loading ...</Text>}
{!isLoading && <Text>Hello JSX World!</Text>}
</SafeAreaView>
)
}
import React from 'react';
import {SafeAreaView, Text} from 'react-native';
export default function App(){
const isLoading = true
const children = isLoading ? (
<Text>Loading ...</Text>
) : (
<Text>Hello JSX World!</Text>
)
return <SafeAreaView>{children}</SafeAreaView>
}
import React from 'react';
import {SafeAreaView, Text} from 'react-native';
export default function App(){
const children = [
<Text>Hello World!</Text>,
<Text>Hello World!</Text>,
<Text>Hello World!</Text>
]
return <SafeAreaView>{children}</SafeAreaView> // 부모 컴포넌트의 자식 컴포넌트 형태
}
import React from 'react';
import {SafeAreaView, Text} from 'react-native';
export default function App(){
const children = [1,2,3].map((i) => <Text>Hello World! {i}</Text>)
return <SafeAreaView>{children}</SafeAreaView>
}
import React from 'react';
import {SafeAreaView, Text} from 'react-native';
export default function App(){
const children = new Array(100).fill(null).map((notUsed, index) => <Text>Hello World! {index}</Text>)
return <SafeAreaView>{children}</SafeAreaView>
}
[Android] FCM PUSH Notification (FCM PUSH 알림) (0) | 2022.03.09 |
---|---|
[React Native] React Native Template TypeScript 에러 해결 방법 (0) | 2021.08.29 |
[React Native] React Native with TypeScript : Hello World (0) | 2021.08.24 |
[React Native] React Native로 Android 앱 개발 시작하기 (Windows) (0) | 2021.08.24 |
[React Native] 개발 환경 구축 in Windows (Scoop, Node.js, VSCode, Android Studio) (0) | 2021.08.23 |