diff --git a/src/NavigationActions.js b/src/NavigationActions.js index 6724e9f703..453c46f2b4 100644 --- a/src/NavigationActions.js +++ b/src/NavigationActions.js @@ -92,6 +92,7 @@ const uri = createAction(URI, payload => ({ const completeTransition = createAction(COMPLETE_TRANSITION, payload => ({ type: COMPLETE_TRANSITION, + key: payload && payload.key, })); const mapDeprecatedNavigateAction = action => { diff --git a/src/navigators/StackNavigator.js b/src/navigators/StackNavigator.js index 7f2abb264a..38273decb5 100644 --- a/src/navigators/StackNavigator.js +++ b/src/navigators/StackNavigator.js @@ -44,7 +44,7 @@ export default (routeConfigMap, stackConfig = {}) => { onTransitionStart={onTransitionStart} onTransitionEnd={(lastTransition, transition) => { const { state, dispatch } = props.navigation; - dispatch(NavigationActions.completeTransition()); + dispatch(NavigationActions.completeTransition({ key: state.key })); onTransitionEnd && onTransitionEnd(); }} /> diff --git a/src/routers/StackRouter.js b/src/routers/StackRouter.js index b9b72396a5..088ede655a 100644 --- a/src/routers/StackRouter.js +++ b/src/routers/StackRouter.js @@ -107,13 +107,13 @@ export default (routeConfigs, stackConfig = {}) => { childRouters[action.routeName] !== undefined ) { return { + key: 'StackRouterRoot', isTransitioning: false, index: 0, routes: [ { routeName: action.routeName, params: action.params, - type: undefined, key: `Init-${generateKey()}`, }, ], @@ -142,6 +142,7 @@ export default (routeConfigs, stackConfig = {}) => { }; // eslint-disable-next-line no-param-reassign state = { + key: 'StackRouterRoot', isTransitioning: false, index: 0, routes: [route], @@ -254,6 +255,7 @@ export default (routeConfigs, stackConfig = {}) => { if ( action.type === NavigationActions.COMPLETE_TRANSITION && + (action.key == null || action.key === state.key) && state.isTransitioning ) { return {