Challenge - 5 Problems
Text Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this Text component display?
Consider this React Native code snippet:
What will the user see on the screen?
import React from 'react';
import { Text } from 'react-native';
export default function App() {
return Hello World ;
}What will the user see on the screen?
React Native
import React from 'react'; import { Text } from 'react-native'; export default function App() { return <Text style={{fontWeight: 'bold', fontSize: 20}}>Hello World</Text>; }
Attempts:
2 left
💡 Hint
Check the style properties applied to the Text component.
✗ Incorrect
The style prop sets fontWeight to 'bold' and fontSize to 20, so the text appears bold and larger than default.
📝 Syntax
intermediate2:00remaining
Which option correctly renders multi-line text in React Native?
You want to display this text with line breaks:
Which code snippet will show the text on two lines?
Hello World
Which code snippet will show the text on two lines?
Attempts:
2 left
💡 Hint
In JSX, how do you insert a newline character inside text?
✗ Incorrect
Using {'\n'} inside Text inserts a newline. Plain '\n' inside JSX text is not interpreted as newline.
❓ lifecycle
advanced2:00remaining
What happens if you update state inside a Text component's onPress?
Given this code:
What will happen when the user taps the text multiple times?
const [count, setCount] = React.useState(0); returnsetCount(count + 1)}>Count: {count} ;
What will happen when the user taps the text multiple times?
React Native
const [count, setCount] = React.useState(0); return <Text onPress={() => setCount(count + 1)}>Count: {count}</Text>;
Attempts:
2 left
💡 Hint
Text supports onPress and state updates cause re-render.
✗ Incorrect
Text supports onPress. Each tap calls setCount to increase count, updating the displayed number.
🔧 Debug
advanced2:00remaining
Why does this Text component not show the expected color?
Look at this code:
Both texts appear black on the screen. Why?
Hello World
Both texts appear black on the screen. Why?
React Native
<Text style={{color: 'red', fontSize: 18}}>Hello</Text>
<Text style={{color: 'blue'}}>World</Text>Attempts:
2 left
💡 Hint
Check if any parent container styles affect text color.
✗ Incorrect
A parent container style can override child text colors. React Native supports color on Text. 'textColor' is invalid.
🧠 Conceptual
expert3:00remaining
How does React Native handle nested Text components?
Consider this code:
What will be the visual result on the screen?
Hello World
What will be the visual result on the screen?
React Native
<Text style={{fontSize: 20}}>
Hello <Text style={{fontWeight: 'bold'}}>World</Text>
</Text>Attempts:
2 left
💡 Hint
Nested Text inherits styles but can override some properties.
✗ Incorrect
The outer Text sets fontSize 20 for all text. The inner Text overrides fontWeight to bold only for 'World'.