0

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.

MattyK14
  • 2,046
  • 2
  • 17
  • 29
  • Do you want to sent do `Scene2` the `someImage` value? – Sebastián Palma May 24 '17 at 21:20
  • No Scene1's component has an object as a prop that I need to pass to Scene2. – MattyK14 May 25 '17 at 12:19
  • You could store it and pass it as its own `prop` within the `Actions.sceneTwo()` – Sebastián Palma May 25 '17 at 13:42
  • The problem is the object is dynamic not static, so I have say Scene1, Scene2, Scene3. Scene1 has a list made up of fetched data. When an item is selected it moves to Scene2 with relevant props of the listitem. I want to carry forth the object to Scene3 from the navBar button. If the Action.Scene3() was being triggered in Scene2's component, I could just attach ({ prop: value )} to it, but I'm triggering the Actions.Scene3() in the Router component. – MattyK14 May 25 '17 at 15:11

1 Answers1

1

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