fix: fix stack nested in tab always getting reset

This commit is contained in:
satyajit.happy
2019-08-28 12:22:15 +02:00
parent d5b4210eb2
commit dead4e826a
2 changed files with 6 additions and 6 deletions

View File

@@ -45,14 +45,12 @@ function StackNavigator({
() =>
navigation.addListener &&
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
const isFocused = navigation.isFocused();
// Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
if (
state.index > 0 &&
navigation.isFocused() &&
!e.defaultPrevented
) {
if (state.index > 0 && isFocused && !e.defaultPrevented) {
// When user taps on already focused tab and we're inside the tab,
// reset the stack to replicate native behaviour
navigation.dispatch({