mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 04:45:19 +08:00
feat: handle route names change
This commit is contained in:
committed by
Satyajit Sahoo
parent
95773de0a3
commit
b775dbaacf
@@ -72,6 +72,21 @@ const TabRouter: Router<Action | CommonAction> = {
|
||||
return state;
|
||||
},
|
||||
|
||||
getStateForRouteNamesChange(state, { routeNames, initialParamsList }) {
|
||||
return {
|
||||
...state,
|
||||
routeNames,
|
||||
routes: routeNames.map(
|
||||
name =>
|
||||
state.routes.find(r => r.name === name) || {
|
||||
name,
|
||||
key: `${name}-${shortid()}`,
|
||||
params: initialParamsList[name],
|
||||
}
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
getStateForAction(state, action) {
|
||||
switch (action.type) {
|
||||
case 'JUMP_TO':
|
||||
@@ -190,4 +205,4 @@ export function TabNavigator(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default createNavigator(TabNavigator);
|
||||
export default createNavigator(TabNavigator);
|
||||
|
||||
Reference in New Issue
Block a user