React native
Core Component 사용 예시
import {Text} from 'react-native'
const RN = () => {
return <Text>Hello, I am your React Native UI!</Text>
}
export default RN;

Custom Component
Component Lifecycle

JSX
import {Text, View} from 'react-native'
const MyJSX = () => {
const name = "Mari"
return(
<View style={{backgroundColor:'blue',flex:0.3}}>
<Text>This is {name === "Maru" ? "Maru" : "who?"}</Text>
<Text>This is Closing Tag</Text>
</View>
)
}
export default MyJSX;

Props = Properties
import {Text, View} from 'react-native'
const ChildComPN = props => {
return (
<View>
<Text> Hello, I am {props.name}</Text>
</View>
)
}
const ParentComPN = () => {
return (
<View>
<ChildComPN name = "Parent1"/>
<ChildComPN name = "Parent2"/>
</View>
)
}
export default ParentComPN

State
import React, {Component} from 'react';
import {Text, View} from 'react-native';
export default class App extends Component {
state = {
myState : 'It will change on clicking it'
}
updateState = () => this.setState({myState : "The state is updated"})
render() {
return (
<View>
<Text onPress={this.updateState} style = {{fontSize:20}}>
{'\n'}
{'\n'}
{this.state.myState}</Text>
</View>
)
}
}
