fix: adjust index when route names are changed

This commit is contained in:
satyajit.happy
2019-07-29 00:59:11 +02:00
parent 04483a4f1b
commit 9ff483a554
4 changed files with 24 additions and 11 deletions

View File

@@ -107,10 +107,15 @@ function StackRouter(options: DefaultRouterOptions) {
},
getStateForRouteNamesChange(state, { routeNames }) {
const routes = state.routes.filter(route =>
routeNames.includes(route.name)
);
return {
...state,
routeNames,
routes: state.routes.filter(route => routeNames.includes(route.name)),
routes,
index: Math.min(state.index, routes.length - 1),
};
},