Challenge - 5 Problems
React Native Starter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this React Native component display?
Consider this React Native component code. What text will appear on the screen when this app runs?
React Native
import React from 'react'; import { Text, View } from 'react-native'; export default function App() { return ( <View> <Text>Hello, React Native!</Text> </View> ); }
Attempts:
2 left
💡 Hint
Look at the Text component inside the View. What string does it contain?
✗ Incorrect
The Text component inside the View displays the string 'Hello, React Native!'. This is the text shown on the screen.
📝 Syntax
intermediate2:00remaining
Which option fixes the syntax error in this React Native code?
This React Native code has a syntax error. Which option fixes it so the app runs correctly?
React Native
import React from 'react'; import { Text, View } from 'react-native'; export default function App() { return ( <View> <Text>Hello World!</Text> </View> ) }
Attempts:
2 left
💡 Hint
Check if all parentheses are properly closed in the return statement.
✗ Incorrect
The return statement opens with a parenthesis but does not close it. Adding the missing closing parenthesis fixes the syntax error.
❓ lifecycle
advanced2:00remaining
When does the useEffect hook run in this React Native component?
Look at this React Native component using useEffect. When will the console.log run?
React Native
import React, { useEffect } from 'react'; import { Text, View } from 'react-native'; export default function App() { useEffect(() => { console.log('Component mounted'); }, []); return ( <View> <Text>Check console</Text> </View> ); }
Attempts:
2 left
💡 Hint
An empty dependency array means the effect runs only once.
✗ Incorrect
useEffect with an empty dependency array runs only once after the component mounts.
advanced
2:00remaining
What happens when you press this button in a React Native app using React Navigation?
Given this button code inside a React Navigation screen, what happens when the user taps it?
React Native
import React from 'react'; import { Button } from 'react-native'; export default function HomeScreen({ navigation }) { return ( <Button title="Go to Details" onPress={() => navigation.navigate('Details')} /> ); }
Attempts:
2 left
💡 Hint
navigation.navigate('Details') changes the screen to 'Details'.
✗ Incorrect
The onPress calls navigation.navigate with 'Details', so the app moves to that screen.
🔧 Debug
expert2:00remaining
Why does this React Native app crash on startup?
This React Native app crashes immediately. What is the cause?
React Native
import React from 'react'; import { Text, View } from 'react-native'; export default function App() { console.log('App rendered'); return ( <View> <Text>Hello</Text> </View> ); }
Attempts:
2 left
💡 Hint
Code after return inside a function is unreachable and invalid.
✗ Incorrect
The console.log after return is unreachable code, which causes a syntax error and crash.