Build: Simple Text Screen
This screen shows a simple text message centered on the screen.
Target UI
--------------------- | | | | | Hello, React! | | | | | ---------------------
--------------------- | | | | | Hello, React! | | | | | ---------------------
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function SimpleTextScreen() { return ( <View style={styles.container}> {/* TODO: Add Text component here */} </View> ); } const styles = StyleSheet.create({ container: { flex: 1, // TODO: Center content horizontally and vertically }, });
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function SimpleTextScreen() { return ( <View style={styles.container}> <Text>Hello, React!</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, });
We added a Text component inside the View to show the message 'Hello, React!'. To center the text, we used justifyContent: 'center' to center vertically and alignItems: 'center' to center horizontally in the container. The container uses flex: 1 to fill the screen space.
--------------------- | | | | | Hello, React! | | | | | ---------------------
Text component in React Native?Text component in React Native?style={{key: value}} with double curly braces for inline styles.const name = 'Anna';
return <Text>Hello, {name}!</Text>name is 'Anna', so it replaces {name} with 'Anna'.return <Text style={{fontSize: 18, color: 'blue'}}>Welcome</Text>;Text component. Which code correctly shows "Good morning" if before noon, otherwise "Good afternoon"?Pass the test and this pattern moves unknown