feat: handle route names change

This commit is contained in:
satyajit.happy
2019-07-16 15:41:16 +02:00
committed by Satyajit Sahoo
parent 95773de0a3
commit b775dbaacf
5 changed files with 110 additions and 6 deletions

View File

@@ -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);