[v5.1.1] iOS: BottomTabs: tab gets initialised after switching to it by default, tabsAttachMode: 'together' not working
Issue Description
On iOS the new tabsAttachMode is not working. By default it uses onSwitchToTab and even when explicitly setting it to 'together', it still initialises only when switching to the tab
Steps to Reproduce / Code Snippets / Screenshots
- Add bottomTabs
- Only the first tab will initialise, the others will initialise after switching to them
- Android works fine 👍
I tried to add a reproducible example but I can't run the iOS playground.
I get this:
error: ~/Projects/react-native-navigation/lib/ios/RNNAnimationConfigurationOptions.h: No such file or directory
Also, running pod install does not work because of this:
[!] CocoaPods could not find compatible versions for pod "OCMock":
In snapshot (Podfile.lock):
OCMock (= 3.5)
In Podfile:
OCMock
None of your spec sources contain a spec satisfying the dependencies: `OCMock, OCMock (= 3.5)`.
You have either:
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Environment
- React Native Navigation version: 5.1.1
- React Native version: 0.60
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): iOS Simulator
@guyca I had the same issue (forgot to tell you on discord) on v4, too.
Seems like tabsAttachmode isn't resolved from defaultOptions, but declaring it in the bottomTabs themselves works. Thanks for reporting 👍
@guyca I declare it when doing a setRoot, with a sideMenu layout. The center part has my bottomTabs, but this seems like it still does not work. I do it like this:
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
name: routes.SideMenu,
},
},
center: {
bottomTabs: {
id: 'bottom-tabs',
children: screens,
options: {
bottomTabs: {
tabsAttachMode: 'together',
},
},
},
},
},
},
});
Edit: I can confirm that it works without the sideMenu btw.
@svenlombaert Thanks for following up. On which platform does it not work?
On iOS. The above I have only tested on iOS though, as on Android, the default looked like it was set on 'together' and was working the first time I tried it (when I created this issue).
just to confirm: if you console.log in the constructor of the components used as roots in the bottomTabs layout - you see only the log of the first component?
Exactly. Usually in debug, I also see which applications started, there's always six logs, my five tabs and the sideMenu. Now I only have two logs, my side menu and the first tab.
Any updates? Still happening to me.
@fedezolk On which version?
@guyca it happens on RNN 4.8.1, too ( I think after version with tabAttachMode)
We'll look into this asap, thansk @vjtc0n
@guyca I am with an older version 4.4.0. In the latest doesn't happen?
@guyca In my case, I don't use side menu, but this bug still appears. Any workaround about it yet?
@vjtc0n #6001 should fix other cases where tabsAttachMode broke. We'll publish another version this week, please test it and let us know if your it's still broken in your use case.
@guyca This is still not working on the latest version.
Having this issue using v7.25.4
@guyca @yogevbd issue also exists in v7.26.0.
Tried setting tabsAttachMode to together and afterInitialTab, but it always behaves like onSwitchToTab and screen flickers while changing tabs for first time for all tabs. Please can you take a look at this.
In my case I found that it was another library that was causing the problem. I was wrapping my screens at the top level with SafeAreaProvider from react-native-safe-area-context, which for some reason blocked the screen from mounting initially, and also caused flickering. Removed it and now everything is smooth!