Complete the code to create a simple View container in React Native.
import React from 'react'; import { [1] } from 'react-native'; export default function App() { return <[1] style={{ flex: 1, backgroundColor: 'lightblue' }} />; }
The View component is the basic container in React Native. It is used to hold other components or style blocks.
Complete the code to nest a Text component inside a View component.
import React from 'react'; import { View, [1] } from 'react-native'; export default function App() { return ( <View style={{ padding: 20 }}> <[1]>Hello, React Native!</[1]> </View> ); }
The Text component is used to display text inside a View in React Native.
Fix the error in the code by completing the import statement correctly.
import React from 'react'; import { View, [1] } from 'react-native'; export default function App() { return <View><Text>Hello!</Text></View>; }
The Text component must be imported to use it inside the View.
Fill both blanks to create a View with a red background and padding of 10.
import React from 'react'; import { View } from 'react-native'; export default function App() { return <View style={{ backgroundColor: [1], padding: [2] }} />; }
The backgroundColor style needs a color string like 'red'. Padding is a number representing spacing inside the View.
Fill all three blanks to create a View with flex layout, centered content, and a blue background.
import React from 'react'; import { View, Text } from 'react-native'; export default function App() { return ( <View style={{ flex: [1], justifyContent: [2], backgroundColor: [3] }}> <Text>Centered Text</Text> </View> ); }
Setting flex to 1 makes the View fill available space. justifyContent 'center' centers children vertically. backgroundColor 'blue' sets the background color.