How to pass data From one Scene to another in ReactNaive

旧巷老猫 提交于 2019-12-13 06:45:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!