Stack pushes are now idempotent

This commit is contained in:
Matt Hamil 2017-05-19 10:53:20 -05:00
parent 8d91753e9c
commit 528b1ad812

View File

@ -72,6 +72,8 @@ export default (
paths[routeName] = { re, keys, toPath: pathToRegexp.compile(pathPattern) }; paths[routeName] = { re, keys, toPath: pathToRegexp.compile(pathPattern) };
}); });
let inProgressNavigationRouteName = null;
return { return {
getComponentForState(state: NavigationState): NavigationComponent { getComponentForState(state: NavigationState): NavigationComponent {
const activeChildRoute = state.routes[state.index]; const activeChildRoute = state.routes[state.index];
@ -138,6 +140,16 @@ export default (
}; };
} }
// Check if action wants to route to the route that is in-progress navigating
if (
inProgressNavigationRouteName !== null &&
inProgressNavigationRouteName === passedAction.routeName
) {
inProgressNavigationRouteName = null;
return false;
}
inProgressNavigationRouteName = passedAction.routeName;
// Check if a child scene wants to handle the action as long as it is not a reset to the root stack // Check if a child scene wants to handle the action as long as it is not a reset to the root stack
if (action.type !== NavigationActions.RESET || action.key !== null) { if (action.type !== NavigationActions.RESET || action.key !== null) {
const keyIndex = action.key const keyIndex = action.key