Complete the code to import the React Native component needed to display text.
import React from 'react'; import { [1] } from 'react-native'; export default function App() { return ( <[1]>Hello, React Native!</[1]> ); }
The Text component is used to display text in React Native.
Complete the code to create a container that centers its children.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View style={styles.[1]> <Text>Centered Text</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, });
The style named container is used to center content with flexbox.
Fix the error in the code to correctly export the App component as default.
import React from 'react'; import { Text } from 'react-native'; function App() { return <Text>Hello!</Text>; } export [1] App;
Use export default to export the main component.
Fill in the blank to create a simple button that shows an alert when pressed.
import React from 'react'; import { Button, Alert } from 'react-native'; export default function App() { return ( <Button title="Press me" onPress={() => [1]('Button pressed!')} /> ); }
Use Alert.alert to show a popup alert in React Native.
Fill all three blanks to create a stateful counter app with a button to increase count.
import React, { [1] } from 'react'; import { View, Text, Button } from 'react-native'; export default function App() { const [count, [2]] = [1](0); return ( <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <Text>Count: {count}</Text> <Button title="Increase" onPress={() => [2](count + 1)} /> </View> ); }
useState is imported to create state. It returns a pair: the current state and a function to update it, here named setCount.
