Skip to content

Commit 7832ed7

Browse files
authored
Merge branch 'master' into master
2 parents 365eec8 + 2e958c9 commit 7832ed7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/routers/StackRouter.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export default (
7575
paths[routeName] = { re, keys, toPath: pathToRegexp.compile(pathPattern) };
7676
});
7777

78+
let inProgressNavigationRouteName = null;
79+
7880
return {
7981
getComponentForState(state: NavigationState): NavigationComponent {
8082
const activeChildRoute = state.routes[state.index];
@@ -141,6 +143,26 @@ export default (
141143
};
142144
}
143145

146+
if (passedAction.type === 'Navigation/BACK') {
147+
inProgressNavigationRouteName = null;
148+
}
149+
150+
if (
151+
action.type === NavigationActions.NAVIGATE &&
152+
passedAction.routeName !== 'DrawerOpen' &&
153+
passedAction.routeName !== 'DrawerClose'
154+
) {
155+
// Check if action wants to route to the route that is in-progress navigating
156+
if (
157+
inProgressNavigationRouteName !== null &&
158+
inProgressNavigationRouteName === passedAction.routeName
159+
) {
160+
inProgressNavigationRouteName = null;
161+
return;
162+
}
163+
inProgressNavigationRouteName = passedAction.routeName;
164+
}
165+
144166
// Check if a child scene wants to handle the action as long as it is not a reset to the root stack
145167
if (action.type !== NavigationActions.RESET || action.key !== null) {
146168
const keyIndex = action.key
@@ -222,6 +244,7 @@ export default (
222244
}
223245

224246
if (action.type === NavigationActions.SET_PARAMS) {
247+
inProgressNavigationRouteName = null;
225248
const lastRoute = state.routes.find(
226249
/* $FlowFixMe */
227250
(route: *) => route.key === action.key
@@ -273,6 +296,7 @@ export default (
273296

274297
if (action.type === NavigationActions.BACK) {
275298
let backRouteIndex = null;
299+
inProgressNavigationRouteName = null;
276300
if (action.key) {
277301
const backRoute = state.routes.find(
278302
/* $FlowFixMe */

0 commit comments

Comments
 (0)