hhoang
hhoang

Reputation: 1

How to pass props between 2 scene in NavigationExperimental React Native using Redux

i am using Naviagtion Experimental and i have a listview, when user select item on listview i will open item detail by using push of Navigation Experimental. I have a issue How to pass props between 2 scene in NavigationExperimental React Native using Redux ? (i am using android)

Thanks.

Upvotes: 0

Views: 1039

Answers (2)

sandeepdhakal
sandeepdhakal

Reputation: 81

The easiest way is to send props using the route object that you already use for navigation.

In your ListView

const route = {key: 'detail', itemId: 123}
<TouchableHighlight
  onPress={() => handleNavigate({type: 'push', route: route}) >
...
</TouchableHighlight>

And in your NavigationCardStack's renderScene, you can pass in the props to your detail view component

renderScene(props) {
  const {route} = props.scene
  ...
  if (route.key === 'detail') {
    return <DetailViewComponent
      goBack={...}
      itemId={route.itemId} />
  }
}

Upvotes: 1

Ata Mohammadi
Ata Mohammadi

Reputation: 3550

I would recommend you to use react-native-router-flux.

You can get it from here : https://github.com/aksonov/react-native-router-flux

It's very easy to pass props with that. for example navigating to component X and passing props :

Actions.X({testProps: 'hello', title: 'Page titile'});

Upvotes: 0

Related Questions