mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-13 17:47:32 +08:00
fix: adjust index when route names are changed
This commit is contained in:
@@ -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),
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user