问题
My Question i have two Scene OnceScene and TwoScene I want to Navigate from OnceScene to TwoScene and at the same time i want to pass some array from 1st the 2nd so for that i have written the below code
this.props.navigator.push({
id: "productdetails",
passProps: {arr: arr[rowID]}
});
you can see i am passing the array in passProps but how can i acess that array in TwoScene Its seems simple but since i am new i dont have much idea.
回答1:
Have you tried using react-native router?
https://github.com/aksonov/react-native-router-flux
Also answering to your question it seems like you are passing the data through props. So on the next screen you can access these props like: this.props.foo (of course you need to declare it on the second screen somehow to access it.)
回答2:
I found what i was missing ,forgot to declare
return (<ProductDetails title="ProductDetails"
navigator={navigator}
{...route.passProps} route={route}
/>)
on my return component. This is the reason i was getting undefined value.
来源:https://stackoverflow.com/questions/42621845/how-to-pass-data-from-one-scene-to-another-in-reactnaive