View
ScrollView
Text
TextInput
Image
TouchableOpacity
HTML | React Native |
---|---|
<div> | <View> |
<p> | <Text> |
<input /> | <TextInput /> |
<button> | <TouchableOpacity /> |
class MyComponent extends React.Component {
render() {
return (
<Text>Hello World</Text>
)
}
}
class (stateful)
const MyComponent = () => (
<Text>Hello World</Text>
)
<MyComponent />
functional (stateless)
vs
Components ➡ React elements - what should appear on the screen.
Styles can be created one of three ways:
inline styles
<Text style={{color: "red"}}>Hello World</Text>
<View style={{width: 300}}>
style object
const styles = {
text: {
color: "red"
}
}
<Text style={styles.text}>Hello World</Text>
StyleSheet
import { StyleSheet, View, Text } from "react-native"
const styles = StyleSheet.create({
container: {
width: 300,
height: 130
},
text: {
color: "red"
}
})
<View style={styles.container}>
<Text style={styles.text}>Hello World</Text>
</View>
StyleSheet.create({...})
code