Manage a set of tabs in the application, handle jumping to tabs, and handle the back button press to jump to the initial tab.
Let’s take a look at a simple tabs router:
1 | const MyApp = TabRouter({ |
RouteConfig
A tabs router has a routeConfig for each possible tab:
1 | const MyApp = TabRouter({ // This is the RouteConfig: |
Each item in the config may have the following:
path
- Specify the path for each tabscreen
- Specify the screen component or child navigatorgetScreen
- Set a lazy getter for a screen component (but not navigators)
Tab Router Config
Config options that are also passed to the router.
initialRouteName
- The routeName for the initial tab route when first loadingorder
- Array of routeNames which defines the order of the tabspaths
- Provide a mapping of routeName to path config, which overrides the paths set in the routeConfigs.backBehavior
- Should the back button cause a tab switch to the initial tab? If yes, set toinitialRoute
, otherwisenone
. Defaults toinitialRoute
behavior.
Supported Actions
The tabs router may respond to the following navigation actions. The router will generally delegate the action handling to a child router, if possible.
- Navigate - Will jump to the routeName if it matches a tab
- Back - Goes to the first tab, if not already selected
- SetParams - An action that a screen dispatches to change the params of the current route.