Challenge - 5 Problems
Drawer Navigator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediateWhat happens when you tap a drawer item?
In a React Native app using Drawer Navigator, what is the expected behavior when a user taps on a drawer item?
Attempts:
2 left
💡 Hint
Think about what a menu in a real app does when you pick an option.
✗ Incorrect
Tapping a drawer item should navigate to the linked screen and close the drawer, just like choosing a menu option in a real app.
❓ lifecycle
intermediateWhen is the drawer content rendered?
In React Navigation's Drawer Navigator, when is the drawer content component rendered?
Attempts:
2 left
💡 Hint
Think about performance and user experience for menus.
✗ Incorrect
The drawer content is mounted once and stays in memory to allow quick opening without delay.
advanced
How to programmatically open the drawer?
Which code snippet correctly opens the drawer programmatically in a React Native app using Drawer Navigator?
React Native
function MyScreen({ navigation }) {
// What code opens the drawer?
}Attempts:
2 left
💡 Hint
Check the official React Navigation docs for drawer methods.
✗ Incorrect
The method openDrawer() is the official way to open the drawer programmatically.
📝 Syntax
advancedIdentify the correct Drawer Navigator setup
Which code snippet correctly sets up a Drawer Navigator with two screens named Home and Profile?
React Native
import { createDrawerNavigator } from '@react-navigation/drawer'; import HomeScreen from './HomeScreen'; import ProfileScreen from './ProfileScreen'; const Drawer = createDrawerNavigator(); function MyDrawer() { return ( // Fill in the drawer navigator ); }
Attempts:
2 left
💡 Hint
Remember the exact component names from the library.
✗ Incorrect
Drawer.Navigator and Drawer.Screen are the correct components. Screen alone is not imported from drawer.
🔧 Debug
expertWhy does the drawer not open on swipe?
You implemented a Drawer Navigator but swiping from the screen edge does not open the drawer. What is the most likely cause?
Attempts:
2 left
💡 Hint
Swipe gestures require special setup in React Native.
✗ Incorrect
React Navigation's drawer gestures need react-native-gesture-handler setup, including wrapping the app root with gestureHandlerRootHOC.
