Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: use the JUMP_TO action for tab change
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
satya164 committed Aug 18, 2019
1 parent 4adb3a9 commit 242625a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/bottom-tabs/src/utils/createTabNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StackActions,
SceneView,
createNavigator,
NavigationActions,
SwitchActions,
} from '@react-navigation/core';

export type InjectedProps = {|
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 242625a

Please sign in to comment.