Key for completion action, to prevent eager didFocus (#3435)

The completion action would previously change the isTransitioning of any state, but this will ensure that the completing navigator only marks its own state as isTransitioning:false. Now, even when transition completion happens immediately on the parent, the child focus event still waits for the child isTransitioning to go false.
This commit is contained in:
Eric Vicenti
2018-02-05 11:33:00 -08:00
committed by Brent Vatne
parent 03fbd98ce4
commit fae1f71fb3
3 changed files with 5 additions and 2 deletions

View File

@@ -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 => {

View File

@@ -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();
}}
/>

View File

@@ -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 {