The View component in React Native is the fundamental building block for creating layouts. It works like a container that supports layout using Flexbox, styling, touch handling, and accessibility controls.
The View component is imported from react-native and is used to group and style child components such as Text, Image, or other Views.
// Basic View container example
import React from "react";
import { View, Text } from "react-native";
export default function App() {
return (
Hello React Native
);
}
This code renders a simple container with text inside it. The View acts as a wrapper that controls layout and positioning.
Adjust the properties below to see how a <View> uses Flexbox to arrange its children. In React Native, flexDirection defaults to column.
// Generated React Native Code
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<Text>1</Text>
<Text>2</Text>
<Text>3</Text>
</View>