0
0
React Nativemobile~20 mins

Drawer Navigator in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Drawer Navigator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What 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?
AThe app crashes because drawer items cannot be tapped.
BThe app navigates to the screen linked to that drawer item and closes the drawer.
CThe drawer stays open and the app reloads the current screen.
DThe drawer closes but the app does not change screens.
Attempts:
2 left
💡 Hint
Think about what a menu in a real app does when you pick an option.
lifecycle
intermediate
2:00remaining
When is the drawer content rendered?
In React Navigation's Drawer Navigator, when is the drawer content component rendered?
AOnly when the drawer is closed.
BOnly when the drawer is opened by the user.
CEvery time the user navigates to a new screen.
DOnce when the app starts and stays mounted in memory.
Attempts:
2 left
💡 Hint
Think about performance and user experience for menus.
navigation
advanced
2:00remaining
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?
}
Anavigation.openDrawer();
Bnavigation.showDrawer();
Cnavigation.toggleDrawer(true);
Dnavigation.navigate('DrawerOpen');
Attempts:
2 left
💡 Hint
Check the official React Navigation docs for drawer methods.
📝 Syntax
advanced
2:00remaining
Identify 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
  );
}
Areturn (<Drawer.Navigator><Drawer.Screen name="Home" component={HomeScreen} /><Drawer.Screen name="Profile" component={ProfileScreen} /></Drawer.Navigator>);
Breturn (<Drawer.Navigator><Screen name="Home" component={HomeScreen} /><Screen name="Profile" component={ProfileScreen} /></Drawer.Navigator>);
Creturn (<Drawer><Screen name="Home" component={HomeScreen} /><Screen name="Profile" component={ProfileScreen} /></Drawer>);
Dreturn (<Drawer.Navigator><Drawer.Screen component={HomeScreen} name="Home" /><Drawer.Screen component={ProfileScreen} name="Profile" /></Drawer.Navigator>);
Attempts:
2 left
💡 Hint
Remember the exact component names from the library.
🔧 Debug
expert
2:00remaining
Why 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?
AThe drawer navigator is missing the initialRouteName prop.
BYou forgot to import React in your component file.
CThe gestureHandlerRootHOC wrapper is missing around the app root.
DYou used Stack Navigator instead of Drawer Navigator.
Attempts:
2 left
💡 Hint
Swipe gestures require special setup in React Native.