728x90
반응형
export default class App extends Component{
render(){
return(
<Car/>
);
}
}
// stateless 컴포넌트 ( 기본적으로 유지하는게 없는 순수한 함수 상태)
function test(testValue){
return <View><Text>테스트1</Text></View>
}
// 또는
const test_2 = () =>{
<View><Text>테스트1 의 다른 방식 </Text></View>
}
/* alt + shift + a
function test2(){
return <Text>This is English</Text>
} */
// stateful 컴포넌트 ( 고유한 상태를 유지하는 컴포넌트 )
class Car extends Component {
render() {
return <Text>This is car</Text>;
}
}
사용예시
export default class App extends Component{
render(){
return(
//<Car/>
<View>
<Header/>
<Main/>
<Footer/>
</View>
);
}
}
class Header extends Component {
render(){
return(
<View>
<Text>HEADER 컴포넌트</Text>
</View>
)
}
}
const Footer = () =>(
<View><Text> Footer 컴포넌트</Text></View>
)
const Main = () =>(
<View><Text> Main 컴포넌트</Text></View>
)
728x90
반응형
'React Native' 카테고리의 다른 글
3. 리엑트 네이티브 생명주기 ( Lifecycle ) (0) | 2020.01.07 |
---|---|
2. props 다루기 (0) | 2020.01.07 |
윈도우 react native 설치 및 환경 (1) | 2019.12.31 |
1. state 다루기 : prop 과 State (0) | 2019.12.30 |
EXPO) 시뮬레이터로 실행해 보기 (1) | 2019.08.22 |