mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-30 09:30:43 +08:00
StackRouter block actions while transitioning (#3469)
The most straightforward fix for two issues is to block all navigation actions while mid-transition of a stack navigator. This will fix: The double-navigate on double tap issue, because the first navigation will start the transition and the second action will be ignored. Will fix the buggy header experience that you can see when going back and forward to a different route quickly. This happens because the next navigate action happens before the completion action. After the fix, the navigate action will be ignored, the user will tap again, and will see a good transition
This commit is contained in:
committed by
Brent Vatne
parent
cf36f22e68
commit
858a0d7a53
@@ -109,7 +109,7 @@ describe('NavigationContainer', () => {
|
||||
// First dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'bar' })
|
||||
NavigationActions.navigate({ routeName: 'bar', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
@@ -119,7 +119,7 @@ describe('NavigationContainer', () => {
|
||||
// Second dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'baz' })
|
||||
NavigationActions.navigate({ routeName: 'baz', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('NavigationContainer', () => {
|
||||
// First dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'bar' })
|
||||
NavigationActions.navigate({ routeName: 'bar', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
@@ -157,28 +157,28 @@ describe('NavigationContainer', () => {
|
||||
// Second dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'baz' })
|
||||
NavigationActions.navigate({ routeName: 'baz', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
// Third dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'car' })
|
||||
NavigationActions.navigate({ routeName: 'car', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
// Fourth dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'dog' })
|
||||
NavigationActions.navigate({ routeName: 'dog', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
// Fifth dispatch
|
||||
expect(
|
||||
navigationContainer.dispatch(
|
||||
NavigationActions.navigate({ routeName: 'elk' })
|
||||
NavigationActions.navigate({ routeName: 'elk', immediate: true })
|
||||
)
|
||||
).toEqual(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user