Search code examples
javascriptreactjsreact-nativereact-native-router-flux

Pass Props From navBar Button Using React-Native-Router-Flux


I have a fairly fleshed out project using react-native-router-flux and I'm trying to pass an object through props. Normally I could call Actions.someKey({ someProp: object }) for the navigation, but I'm trying to navigate using the rightButtonImage where it doesn't have access to the component's props.

For instance:

Router.js

<Router>
  <Scene1
    rightButtonImage={someImage}
    onRight={() => Actions.sceneTwo()}
  />
  <Scene2 key="sceneTwo" />
</Router>

I want to pass an object that Scene1's component has access to, when I move to Scene2.


Solution

  • It can be helpful for you: In each component i.e in componentDidMount you can do something like that:

    Actions.refresh({
     rightTitle: "Next",
     rightButtonTextStyle: {color: 'red'},
     onRight: this.goSomewhere, 
     rightButtonImage: someImage
    })