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

[V2] topBar passProps lost after navigating back for custom component

Open andresfcamacho opened this issue 7 years ago • 10 comments

It looks like this was originally reported in https://github.com/wix/react-native-navigation/issues/3803 but the issue was closed as it was reported in 2.0 and commenters saying it might be fixed in later versions but I'm on 2.15.0 and it is still happening.

Steps to Reproduce / Code Snippets / Screenshots

Basically the first time the passProps of 'Goals' below works correctly. Then if you navigate away and then via the bottomTabs tap it again, the passProps are missing.

const homeRoot = {
  bottomTabs: {
    id: 'BottomTabsId',
    options: {
      bottomTabs: {
        currentTabIndex: 0
      }
    },
    children: [
      {
        stack: {
          children: [{
            component: {
              name: screens.GOALS_CONTAINER,
              options: {
                topBar: {
                  title: {
                    component: {
                      name: screens.HEADER_TITLE_WITH_WEEK,
                      passProps: {
                        label: 'Goals'
                      },
                    }
                  },
                  leftButtons: [],
                  rightButtons: [commonNavigation.agentButtonConfig],
                },
                bottomTab: {
                  icon: NavIconGoals,
                  selectedIconColor: blue2,
                  iconInsets: { top: 0, left: 0, bottom: -8, right: 0 },
                  titleDisplayMode: 'alwaysHide',
                },
              },
            },
          }]
        }
      },
      ...
     ]
  }

 Navigation.setRoot({ root: homeRoot })

Environment

  • React Native Navigation version: 2.15.0
  • React Native version: 0.57.0
  • Platform(s) (iOS, Android, or both?): IOS (haven't checked Android)
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator

andresfcamacho avatar Mar 21 '19 15:03 andresfcamacho

Seeing the same issue in IOS as well with our custom topbar. First rendering works and sets the text than when I navigate to the next page and come back the text shows for a moment and then disappears.

"react-native": "0.59.2", "react-native-navigation": "2.15.0", IOS Iphone X 12.2 emulation.

eyes2design avatar Mar 28 '19 22:03 eyes2design

Could be related to this: https://github.com/wix/react-native-navigation/pull/4929

jfrolich avatar Mar 30 '19 04:03 jfrolich

Should be resolved by #4942, published in 2.17.0

guyca avatar Apr 14 '19 05:04 guyca

@guyca I was having this issue as well, until I upgraded to 2.17.0 and it worked!... in the simulator only 😞 When I try this on my iPhone, I'm seeing the error again (works on Android).

Simulator: ScreenRecording20190417at4 (1)

Physical device: ScreenRecording20190417at4

Any thoughts here?

adamgrossman avatar Apr 17 '19 23:04 adamgrossman

Actually custom components are completely not working for me in 2.17.0 (via mergeOptions). Perhaps it makes sense to roll back to the earlier code (before the two breaking changes) and only commit once it's properly tested?

jfrolich avatar Apr 18 '19 07:04 jfrolich

@jfrolich What isn't working? @andresfcamacho can you please try v2.17.0-snapshot.281 ?

cc @yogevbd

guyca avatar Apr 18 '19 08:04 guyca

For whatever reason, my post from before is no longer an issue. The title in my topBar stays as it should.

A quick note - as I was testing out v2.17.0-snapshot.281, my bottom tabs currentTabIndex wasn't working as expected. The following code no longer selected the right index.

Navigation.mergeOptions('BottomTabsId', {
  bottomTabs: {
    currentTabIndex: 2
  }
})

This is not related to the original thread, so no need to respond to this, but in case this was an unexpected side effect of the snapshot, I wanted to share. I reverted the upgrade and the issue went away.

adamgrossman avatar Apr 18 '19 20:04 adamgrossman

@adamgrossman Can you please try with 2.17.0-snapshot.283? I believe that was fixed yesterday.

guyca avatar Apr 19 '19 05:04 guyca

@jfrolich What isn't working? @andresfcamacho can you please try v2.17.0-snapshot.281 ?

cc @yogevbd

Sorry about my reaction, thank you for maintaining the project, I was just a bit frustrated about stuff breaking.

It doesn't show the custom component for me anymore in 2.17.0 (props changed, and topbar visibility set using mergeOptions). I'll try to reproduce it.

jfrolich avatar Apr 19 '19 08:04 jfrolich

@jfrolich Can you please try version 2.17.0-snapshot.283? The issue should be fixed there. No worries, I understand the frustration

guyca avatar Apr 19 '19 09:04 guyca