React Navigation Flashcards
createNativeStackNavigator
is a function that returns an object containing 2 properties: Screen and Navigator.
Both are React components used for configuring the navigator.
NavigationContainer
is a component which manages our navigation tree and contains the navigation state.
The navigation container must wrap all navigators structure and is rendered at the root of our app, which is usually the component exported from App.js.
Navigation State
is the state where React Navigation stores the navigation structure and history of the app.
What does the navigation state look like?
const state = {
type: ‘stack’,
key: ‘stack-1’,
routeNames: [‘Home’, ‘Profile’,
‘Settings’],
routes: [
{ key: ‘home-1’, name:
‘Home’, params: { sortBy:
‘latest’ } },
{ key: ‘settings-1’, name:
‘Settings’ },
],
index: 1,
stale: false,
};
Stack.Navigator
is a component that takes route configuration as its children with additional props for configuration and renders our content.
The Navigator should contain Screen elements as its children to define the configuration for routes.
Stack.Screen
requires a name prop which refers to the name of the route
requires component prop which specifies the component to render for the route.