0

I am using react-native-navigation v2 from Wix, trying to push a screen to an existing stack. Here is my push code:

        Navigation.push(this.props.componentId, {
          component: {
            name: 'chapel.search'
          }
        })

And my options object

  static options (passProps) {
    console.log('Firing static method')
    return {
      component: {
        name: 'chapel.search',
        topBar: {
          visible: true,
          leftButtons: [
            {
              id: 'back',
              testID: 'back',
              icon: require('../../Images/back.png')
            }
          ],
          title: {
            component: {
              name: 'chapel.navtitle',
              alignment: 'center',
              passProps: { text: 'Search' }
            }
          },
          rightButtons: []
        }
      }
    }
  }

I never see the log statement and the topbar options do not change. Should they?

When I use Navigation.mergeOptions with the above options object in the constructor of my target screen, the options appear, so this is what I am using for now.

Using android, have not tested with iOS as yet. Will update when I do.

Justin Lane
  • 368
  • 1
  • 2
  • 13

1 Answers1

0

I'm originating static options like this in my component:

 static get options() {
    return {
        ...
    }
 }

And when i push from another screen and want to override some defaults, i do it like below:

Navigation.push(this.props.componentId, {
    component: {
      name: 'chapel.search',
      passProps: {
        myProp: myprop1
      },
      options: {
        topBar: {
          title: {
            text: newTitleOverridingStaticOne
          }
        }
      }
    }
});

I don't know if static options (passProps){...} is valid, but you can try like i show above to check if it is resolved

angelos_lex
  • 1,593
  • 16
  • 24