Navigation in React #
It’s done using - React Navigation (lib), a very popular lib (has become like de-facto).
An abstraction for ‘simple’ navigation. Since mobile apps doesn’t have a construct of URLs.
The library introduces concepts like
- “Screens”
- “name” (analogue of URL/route used in ReactRouter). “/” is not something.
- “Stack” - it maintains a stack. analogue of History API (of web)
- Navigator (routes markup). Each element points to a screen component.
- Supports individual (of course)
- Supports groups too
- Programmatic navigation - hooks for it.
Setup
- Provider/wrapper -
Stack.Navigator
More stuff
- Navigator can pass
initialParams
to the screen being rendered. - Provides some default style for any screen.
- Screen can be provided with styles
screenOptions
- Navigator markup supports two kind of children:
- Supports individual (of course)
- Supports groups too. Can be nested.
- Tab navigation - bottom tabs (e.g. Zomato bottom).
NavigationContainer
,Tab.Navigator
,Tab.Screen
- how to set up - directly use inside the Navigator (route markup), of course using a component prop.
- Drawer navigation - side bar (collapsible)
- how to set up - directly use inside the Navigator (route markup), of course using a component prop.
- Other navs - there are other things.
- Combination of stuff - of course, can be done.