A Stack Navigator manages a stack of screens where you can push new screens on top or pop back to previous ones, like a stack of cards.
Click to reveal answer
beginner
How do you navigate to a new screen using Stack Navigator?
You use the navigation prop's navigate('ScreenName') method to push a new screen onto the stack.
Click to reveal answer
beginner
What happens when you call navigation.goBack() in a Stack Navigator?
It removes the current screen from the stack and shows the previous screen, like going back in history.
Click to reveal answer
intermediate
How do you set the initial screen in a Stack Navigator?
You set the initialRouteName property in the Stack Navigator configuration to the screen you want to show first.
Click to reveal answer
beginner
Why is Stack Navigator useful in mobile apps?
It mimics natural screen transitions and back behavior, making navigation simple and intuitive for users.
Click to reveal answer
Which method pushes a new screen onto the stack in React Native Stack Navigator?
Anavigation.goBack()
Bnavigation.reset()
Cnavigation.popToTop()
Dnavigation.navigate('ScreenName')
✗ Incorrect
The navigate method pushes a new screen onto the stack.
What does navigation.goBack() do in Stack Navigator?
AReturns to the previous screen
BCloses the app
CPushes a new screen
DReloads the current screen
✗ Incorrect
It removes the current screen and shows the previous one.
How do you specify which screen shows first in a Stack Navigator?
AinitialScreen
BinitialRouteName
CstartRoute
DfirstScreen
✗ Incorrect
The initialRouteName property sets the first screen.
Which of these is NOT a feature of Stack Navigator?
ABack button support
BScreen stacking
CTab bar navigation
DScreen transition animations
✗ Incorrect
Tab bar navigation is handled by a different navigator, not Stack Navigator.
What kind of user experience does Stack Navigator provide?
AHierarchical screen navigation with back support
BNo navigation at all
CRandom screen jumps
DFlat list of screens
✗ Incorrect
Stack Navigator provides hierarchical navigation with back support.
Explain how Stack Navigator manages screens in a React Native app.
Think about how a stack of cards works.
You got /4 concepts.
Describe how to set up and use Stack Navigator to navigate between two screens.
Start from creating the navigator and then moving between screens.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a Stack Navigator in React Native?
easy
A. To fetch data from an API
B. To style components with CSS
C. To manage screen navigation like a stack of pages
D. To handle user input events
Solution
Step 1: Understand navigation concepts
Stack Navigator organizes screens so you can move forward and back like a stack of pages.
Step 2: Identify the correct purpose
It is not for styling, fetching data, or handling input but for navigation.
Final Answer:
To manage screen navigation like a stack of pages -> Option C
Quick Check:
Stack Navigator = navigation management [OK]
Hint: Stack Navigator stacks screens for forward/back navigation [OK]
Common Mistakes:
Confusing navigation with styling
Thinking it handles data fetching
Assuming it manages user input
2. Which of the following is the correct way to wrap your app with a stack navigator?
easy
A.
B.
C.
D.
Solution
Step 1: Recognize correct nesting
The NavigationContainer must wrap the entire navigator, which contains Stack.Navigator and its screens.
Step 2: Check each option's structure
Only <NavigationContainer><Stack.Navigator><Stack.Screen name="Home" component={HomeScreen} /></Stack.Navigator></NavigationContainer> correctly wraps Stack.Navigator inside NavigationContainer and includes Stack.Screen.
Final Answer:
<NavigationContainer><Stack.Navigator><Stack.Screen name="Home" component={HomeScreen} /></Stack.Navigator></NavigationContainer> -> Option A
Quick Check:
NavigationContainer wraps Stack.Navigator [OK]
Hint: NavigationContainer wraps Stack.Navigator, which holds screens [OK]
Common Mistakes:
Placing Stack.Screen outside Stack.Navigator
Wrapping Stack.Screen directly in NavigationContainer
Incorrect nesting order of components
3. Given this code snippet, what screen will be shown first when the app runs?
5. You want to navigate from the Home screen to the Details screen using a Stack Navigator. Which code snippet correctly performs this navigation inside a button press handler?