mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
fix: use the JUMP_TO action for tab change
The index change event fires after swipe animation. If you quickly navigate to a new screen in stack before animation finishes, the index change event will fire after the previous navigation event. By this time, the tab navigator is not focused anymore. Using the JUMP_TO action instead of NAVIGATE avoids this issue.
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
StackActions,
|
||||
SceneView,
|
||||
createNavigator,
|
||||
NavigationActions,
|
||||
SwitchActions,
|
||||
} from '@react-navigation/core';
|
||||
|
||||
export type InjectedProps = {|
|
||||
@@ -160,8 +160,17 @@ export default function createTabNavigator(TabView: React.ComponentType<*>) {
|
||||
this.setState({ isSwiping: false });
|
||||
};
|
||||
|
||||
_jumpTo = routeName =>
|
||||
this.props.navigation.dispatch(NavigationActions.navigate({ routeName }));
|
||||
_jumpTo = routeName => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
navigation.dispatch(
|
||||
SwitchActions.jumpTo({
|
||||
routeName,
|
||||
key: navigation.state.key,
|
||||
preserveFocus: true,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
_isTabPress: boolean = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user