callstack / callstack/react-native-pager-view

onPageSelected is triggering with e.nativeEvent.position==0 after leaving tabview

Aperta
#895 7 commenti 0 reazioni 1 assegnatario Rivendicata da @MrRefactor Vedi su GitHub
android
Lingua principale
TypeScript
Stelle
3.4k
Fork
476
Merge medio
10g 21h
PR unite (30g)
2

Descrizione

## Environment

Android V15 only, iOS not affected

React Native 0.74.5
"react-native-pager-view": "~6.4.1",
"react-native-tab-view": "~3.5.2",
"@react-navigation/stack": "~6.4.1",
"@react-navigation/material-top-tabs": "~6.6.14",

## Description

I'm using `@react-navigation/material-top-tabs`. When I navigate to a view that's not part of the tab navigator, but still in a stack, it triggers a _onPageSelected originating from `react-native-pager-view` that causes the navigation to navigate away from the current view and to the first tab of the pager.
Note, it might be triggering _onPageScrollStateChanged also? The RN debugger is finicky and sometimes it was one or the other.

A detailed description [is provided here](https://github.com/react-navigation/react-navigation/issues/12129#issuecomment-2450593458) with some debugging.

## Reproducible Demo

https://snack.expo.dev/@phazei/react-native-material-tab-bug?platform=android

On android, click the second tab, then click the link on the second tab and you can see it blink to the hello screen, and then be forced back to tab 1.

This was the minimal example, but in production, it actually lets it get to the hello screen, but then clicking another navigation link that's a sibling to hello, forces it back to tab 1. It's caused by the same _onPageSelected or _onPageScrollStateChanged.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.