mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-06 22:39:41 +08:00
fix: don't handle prune if there's only one route
This was preventing the action from bubbling up which would prevent the screen from getting removed
This commit is contained in:
@@ -536,18 +536,21 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
|
||||
if (action.type === StackActions.POP && prune === false && key) {
|
||||
const index = state.routes.findIndex((r) => r.key === key);
|
||||
const count = Math.max(index - (n == null ? 1 : n) + 1, 1);
|
||||
const routes = state.routes
|
||||
.slice(0, count)
|
||||
.concat(state.routes.slice(index + 1));
|
||||
|
||||
if (routes.length) {
|
||||
return {
|
||||
...state,
|
||||
routes,
|
||||
index: routes.length - 1,
|
||||
isTransitioning: immediate !== true,
|
||||
};
|
||||
if (index > 0) {
|
||||
const count = Math.max(index - (n ?? 1) + 1, 1);
|
||||
const routes = state.routes
|
||||
.slice(0, count)
|
||||
.concat(state.routes.slice(index + 1));
|
||||
|
||||
if (routes.length) {
|
||||
return {
|
||||
...state,
|
||||
routes,
|
||||
index: routes.length - 1,
|
||||
isTransitioning: immediate !== true,
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let backRouteIndex = state.index;
|
||||
|
||||
Reference in New Issue
Block a user