A Drawer Navigator is a side menu that slides in from the left or right of the screen. It helps users navigate between different screens by selecting options from the drawer.
Click to reveal answer
intermediate
How do you open the drawer programmatically in React Native?
You can open the drawer by calling the navigation method navigation.openDrawer() inside a component that has access to the navigation prop.
Click to reveal answer
beginner
Which package provides Drawer Navigator in React Native?
The Drawer Navigator is provided by the @react-navigation/drawer package, which works with @react-navigation/native.
Click to reveal answer
beginner
What component wraps your app to enable Drawer Navigation?
You wrap your app with NavigationContainer from @react-navigation/native and then use createDrawerNavigator() to define the drawer screens.
Click to reveal answer
intermediate
How can you customize the drawer content?
You can customize the drawer by passing a drawerContent prop to the Drawer Navigator. This lets you provide a custom React component for the drawer menu.
Click to reveal answer
Which method opens the drawer in React Navigation?
Anavigation.openDrawer()
Bnavigation.showDrawer()
Cnavigation.toggleDrawer()
Dnavigation.drawerOpen()
✗ Incorrect
The correct method to open the drawer is navigation.openDrawer().
Which package do you install to use Drawer Navigator?
A@react-navigation/stack
B@react-navigation/drawer
Creact-native-drawer
Dreact-navigation-drawer
✗ Incorrect
Drawer Navigator is provided by the @react-navigation/drawer package.
What component must wrap your app to use navigation?
AAppContainer
BDrawerProvider
CNavigationWrapper
DNavigationContainer
✗ Incorrect
NavigationContainer from @react-navigation/native wraps the app to enable navigation.
Where does the drawer usually slide in from?
ALeft or Right
BBottom
CTop
DCenter
✗ Incorrect
The drawer slides in from the left or right side of the screen.
How do you customize the drawer menu?
ABy editing the default drawer styles
BBy using a different navigator
CBy passing a drawerContent prop with a custom component
DBy changing the drawer background color only
✗ Incorrect
You customize the drawer by passing a drawerContent prop with your own React component.
Explain how to set up a basic Drawer Navigator in a React Native app.
Think about the packages, components, and steps to show a side menu.
You got /5 concepts.
Describe how you can open and close the drawer programmatically.
Remember the navigation methods related to drawer control.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a Drawer Navigator in React Native?
easy
A. To create a side menu for switching between screens easily
B. To handle API requests in the app
C. To style components with CSS
D. To manage app state globally
Solution
Step 1: Understand Drawer Navigator role
A Drawer Navigator provides a side menu that lets users switch screens easily.
Step 2: Compare with other options
The other options relate to API requests, styling components, and global state management, not navigation menus.
Final Answer:
To create a side menu for switching between screens easily -> Option A
Quick Check:
Drawer Navigator = Side menu navigation [OK]
Hint: Drawer Navigator = side menu for screen switching [OK]
Common Mistakes:
Confusing Drawer Navigator with state management
Thinking it styles components
Mixing it up with API handling
2. Which of the following is the correct way to add a screen named 'Home' to a Drawer Navigator?
easy
A.
B.
C.
D.
Solution
Step 1: Check required props for Drawer.Screen
Drawer.Screen needs a 'name' and a 'component' prop to work correctly.
Step 2: Validate each option
<Drawer.Screen name="Home" component={HomeScreen} /> correctly uses both 'name' and 'component'. The other options miss one or both props.
Final Answer:
<Drawer.Screen name="Home" component={HomeScreen} /> -> Option C
Quick Check:
Drawer.Screen requires name and component [OK]
Hint: Drawer.Screen needs both name and component props [OK]
Common Mistakes:
Omitting the 'name' prop
Omitting the 'component' prop
Using incorrect JSX syntax
3. Given this code snippet, what will happen when the app runs?
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import HomeScreen from './HomeScreen';
import ProfileScreen from './ProfileScreen';
const Drawer = createDrawerNavigator();
export default function App() {
return (
);
}
medium
A. The app crashes because NavigationContainer is missing
B. The app shows a side menu with Home and Profile screens to switch between
C. Only the Home screen is shown without a menu
D. The drawer menu appears but screens are not accessible
Solution
Step 1: Check NavigationContainer usage
The code wraps Drawer.Navigator inside NavigationContainer, which manages navigation state properly.
Step 2: Verify Drawer.Screen setup
Two screens, Home and Profile, are added correctly to the drawer.
Final Answer:
The app shows a side menu with Home and Profile screens to switch between -> Option B
Quick Check:
NavigationContainer + Drawer.Screen = working drawer menu [OK]
Hint: NavigationContainer wraps Drawer.Navigator for working menu [OK]
Common Mistakes:
Forgetting NavigationContainer causes errors
Adding screens outside Drawer.Navigator
Not providing component prop to Drawer.Screen
4. Identify the error in this Drawer Navigator setup:
A. Drawer.Navigator should be inside a View component
B. Drawer.Screen components are missing the 'name' prop
C. HomeScreen and SettingsScreen components are not imported
D. Missing NavigationContainer wrapping the Drawer.Navigator
Solution
Step 1: Check for NavigationContainer presence
The code does not wrap Drawer.Navigator inside NavigationContainer, which is required to manage navigation state.
Step 2: Verify other props and imports
Drawer.Screen components have 'name' and 'component' props, so no issue there. The question does not show imports, but the main error is missing NavigationContainer.
Final Answer:
Missing NavigationContainer wrapping the Drawer.Navigator -> Option D
Quick Check:
NavigationContainer is required to wrap navigators [OK]
Hint: Always wrap Drawer.Navigator in NavigationContainer [OK]
5. You want to customize the drawer menu to show a custom header and add a logout button at the bottom. Which approach correctly applies this customization in a Drawer Navigator?
hard
A. Use the drawerContent prop on Drawer.Navigator to provide a custom component with header and logout button
B. Add a Drawer.Screen named 'Logout' with a button component
C. Wrap each screen component with a header and logout button manually
D. Use screenOptions to add header and logout button globally
Solution
Step 1: Understand drawer customization options
The drawerContent prop lets you replace the default drawer menu with a custom component where you can add headers and buttons.
Step 2: Evaluate other options
Add a Drawer.Screen named 'Logout' with a button component adds a screen, not a menu button. Wrap each screen component with a header and logout button manually duplicates UI in each screen, not efficient. Use screenOptions to add header and logout button globally controls screen headers, not drawer content.
Final Answer:
Use the drawerContent prop on Drawer.Navigator to provide a custom component with header and logout button -> Option A
Quick Check:
drawerContent prop customizes drawer UI [OK]
Hint: Use drawerContent prop for custom drawer UI [OK]
Common Mistakes:
Adding logout as a screen instead of drawer content
Trying to add buttons via screenOptions
Manually adding UI inside each screen
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.