Complete the code to display a simple text message in React Native.
import React from 'react'; import { View, [1] } from 'react-native'; export default function App() { return ( <View> <[1]>Hello, world!</[1]> </View> ); }
The Text component is used to display text in React Native.
Complete the code to style the Text component with a font size of 20.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View> <Text style=[1]>Styled Text</Text> </View> ); } const styles = StyleSheet.create({ bigText: { fontSize: 20, }, });
Use styles.bigText to apply the defined style object to the Text component.
Fix the error in the code by completing the Text component usage correctly.
import React from 'react'; import { View, Text } from 'react-native'; export default function App() { return ( <View> <Text [1]>Incorrect usage</Text> </View> ); }
The style prop must be passed as an object inside double curly braces: style={{fontSize: 18}}.
Fill both blanks to create a Text component that is bold and blue.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View> <Text style=[1]>[2]</Text> </View> ); } const styles = StyleSheet.create({ boldBlue: { fontWeight: 'bold', color: 'blue', }, });
Use styles.boldBlue for the style and a string for the text content.
Fill all three blanks to create a Text component with dynamic content and style.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { const name = 'Alice'; return ( <View> <Text style=[1]>[2] {name}[3]</Text> </View> ); } const styles = StyleSheet.create({ greeting: { fontSize: 22, color: 'green', }, });
Use styles.greeting for style, and add 'Hello,' before the name and '!' after for a friendly greeting.