Description
Hey,
Was testing expo56 with react-navigation with the native tab bar and switching tabs wasn't working in an archive build on ios. Here's an ai summary of the issue which fixes it for me:
RNSTabsHostComponentView navigation state observer never registered in release builds
In RNSTabsHostComponentView.mm, initState registers the view as a navigation state observer using:
RCTAssert([_controller addNavigationStateObserver:self],
@"[RNScreens] Failed to register ...");
In release builds, RCTAssert expands to do {} while (false) and does not evaluate its argument. This means [_controller
addNavigationStateObserver:self] is never called in release/archive builds, leaving _observerRegistry._observers permanently
empty. As a result, emitDidUpdateStateTo: iterates zero observers and tabsContainer:didUpdateStateTo:withContext: is never called
— so onTabSelected events are never dispatched to JS.
The fix is to separate the call from the assertion:
BOOL observerRegistered = [_controller addNavigationStateObserver:self];
RCTAssert(observerRegistered, @"[RNScreens] Failed to register ...");
This only manifests when using the new Tabs API (Tabs.Host / Tabs.Screen). Debug builds are unaffected because RCTAssert evaluates its condition in debug mode.
Steps to reproduce
React navigation tab bar tab switching does nothing on ios release builds
Snack or a link to a repository
should be clear from the code above
Screens version
4.25.0-beta.3
React Native version
0.85.3
Platforms
iOS
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
Description
Hey,
Was testing expo56 with react-navigation with the native tab bar and switching tabs wasn't working in an archive build on ios. Here's an ai summary of the issue which fixes it for me:
Steps to reproduce
React navigation tab bar tab switching does nothing on ios release builds
Snack or a link to a repository
should be clear from the code above
Screens version
4.25.0-beta.3
React Native version
0.85.3
Platforms
iOS
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes