mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-06 17:34:59 +08:00
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:
committed by
Brent Vatne
parent
03fbd98ce4
commit
fae1f71fb3
@@ -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 => {
|
||||
|
||||
@@ -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();
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user