react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[v5.1.1] iOS: BottomTabs: tab gets initialised after switching to it by default, tabsAttachMode: 'together' not working

Open svenlombaert opened this issue 6 years ago • 18 comments

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

svenlombaert avatar Feb 20 '20 15:02 svenlombaert

@guyca I had the same issue (forgot to tell you on discord) on v4, too.

vjtc0n avatar Feb 21 '20 09:02 vjtc0n

Seems like tabsAttachmode isn't resolved from defaultOptions, but declaring it in the bottomTabs themselves works. Thanks for reporting 👍

guyca avatar Feb 23 '20 06:02 guyca

@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 avatar Feb 24 '20 14:02 svenlombaert

@svenlombaert Thanks for following up. On which platform does it not work?

guyca avatar Feb 25 '20 09:02 guyca

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).

svenlombaert avatar Feb 25 '20 09:02 svenlombaert

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?

guyca avatar Feb 25 '20 09:02 guyca

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.

svenlombaert avatar Feb 25 '20 09:02 svenlombaert

Any updates? Still happening to me.

fedezolk avatar Mar 04 '20 15:03 fedezolk

@fedezolk On which version?

guyca avatar Mar 05 '20 09:03 guyca

@guyca it happens on RNN 4.8.1, too ( I think after version with tabAttachMode)

vjtc0n avatar Mar 05 '20 09:03 vjtc0n

We'll look into this asap, thansk @vjtc0n

guyca avatar Mar 05 '20 10:03 guyca

@guyca I am with an older version 4.4.0. In the latest doesn't happen?

fedezolk avatar Mar 05 '20 13:03 fedezolk

@guyca In my case, I don't use side menu, but this bug still appears. Any workaround about it yet?

vjtc0n avatar Mar 11 '20 03:03 vjtc0n

@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 avatar Mar 11 '20 07:03 guyca

@guyca This is still not working on the latest version.

svenlombaert avatar Nov 23 '20 17:11 svenlombaert

Having this issue using v7.25.4

ernestasg152 avatar Mar 09 '22 14:03 ernestasg152

@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.

hrca-writeups avatar Mar 16 '22 21:03 hrca-writeups

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!

ernestasg152 avatar Jul 07 '22 17:07 ernestasg152