mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-27 22:56:07 +08:00
fix: fix stack nested in tab always getting reset
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user