View
is the most fundamental component for building a UI in react native.
- View is a container that supports layout with flexbox, style, some touch handling, and accessibility controls.
View
maps directly to the native view equivalent on whatever platform React Native is running on, whether that is a UIView
, <div>
, android.view
, etc.
View
is designed to be nested inside other views and can have 0 to many children of any type.
- This example creates a
View
that wraps two colored boxes and a text component in a row with padding.
class ViewColoredBoxesWithText extends Component {
render() {
return (
<View
style={{
flexDirection: 'row',
height: 100,
padding: 20,
}}>
<View style={{backgroundColor: 'blue', flex: 0.3}} />
<View style={{backgroundColor: 'red', flex: 0.5}} />
<Text>Hello World!</Text>
</View>
);
}
}