[iOS] TabView does not switch tabs / snaps back even though index updates
Environment
- react-native: 0.77
- react-native-tab-view: 4.0.5
- react-native-pager-view: 7.0.2 (also tried 6.9.1)
- Platform: iOS
- New Architecture: Enabled
Description
On iOS, tabs do not switch correctly when using react-native-tab-view with react-native-pager-view.
onIndexChange is triggered and the state index updates correctly, but the UI does not stay on the selected tab.
Observed behavior:
- pressing a tab does not visibly switch to that tab
- swiping sometimes looks like it changes page briefly, then snaps back to the first tab
- Android works as expected with the same code
Expected behavior
When a tab is pressed or swiped to, the selected tab should stay active and the scene should update correctly.
Actual behavior
On iOS:
- tab press triggers
onIndexChange - state updates
- but the visible page does not remain on the selected tab
- sometimes it briefly changes and returns back to the first tab
Notes
- Android works correctly
- issue reproduced on iOS
- New Architecture is enabled
- upgrading/downgrading app-side code paths did not resolve it
- side effects inside
onIndexChangewere removed for testing, but the issue still persisted
Additional notes
- I also tested the latest
react-native-pager-viewversion. - On iOS, that version threw:
Unimplemented component <RNCViewPager>. - Because of that, I downgraded back to
7.0.2for testing. - The tab switching issue still persists on
7.0.2.
Question
Is this a known iOS/New Architecture regression with react-native-pager-view 7.0.2?
please try with 8.0.0
@MrRefactor Thank you for your feedback. I had previously tried version 8.0.0, but I'm getting the following error for iOS:
I also tried it with version 7.x here: https://github.com/callstack/react-native-pager-view/issues/1065 and got the same error. I didn't get the "Unimplemented component:
Same issue, any solution ?
@RN-Nitin I couldn't fix this error, so I wrote a custom iOS tabview component.
@RN-Nitin @hcrnln could you verify it with changes from #1077 ? Please make sure you have latest rn-tab-view version as well.
Hi @MrRefactor
I tested the fix from #1077 by installing the commit b53ce4a, but it didn’t resolve the issue on my side.
I’m using the latest versions of the related packages:
- react: 18.3.1
- react-native: 0.77.0
- react-native-navigation: 8.8.1
- react-native-tab-view: 4.3.0
Also, I’m running with the New Architecture enabled and Hermes.
This seems related to: https://github.com/wix/react-native-navigation/issues/8271
Let me know if you’d like logs or a minimal reproduction.