React native 如何在ReactNaive中将数据从一个场景传递到另一个场景

React native 如何在ReactNaive中将数据从一个场景传递到另一个场景,react-native,react-native-android,react-native-ios,React Native,React Native Android,React Native Ios,我的问题是我有两个场景onscene和twosecene我想从onscene导航到twosecene,同时我想从第1个到第2个传递一些数组,因此我编写了下面的代码 this.props.navigator.push({ id: "productdetails", passProps:{arr:arr[rowID]} 您可以看到我正在通过passProps中的数组,但我如何在twosecene中访问该数组似乎很简单,但由于我是新手,我不太清楚。您尝试过使用react native r

我的问题是我有两个场景
onscene
twosecene
我想从
onscene
导航到
twosecene
,同时我想从第1个到第2个传递一些数组,因此我编写了下面的代码

 this.props.navigator.push({
     id: "productdetails",
passProps:{arr:arr[rowID]}


您可以看到我正在通过
passProps
中的数组,但我如何在
twosecene
中访问该数组似乎很简单,但由于我是新手,我不太清楚。

您尝试过使用react native router吗


同样,在回答您的问题时,您似乎正在通过道具传递数据。因此,在下一个屏幕上,您可以访问这些道具,如:this.props.foo(当然,您需要在第二个屏幕上以某种方式声明才能访问它。)

我找到了我缺少的东西,忘记声明了

  return (<ProductDetails title="ProductDetails"
return()


在我的返回组件上。这就是我得到未定义值的原因。

为什么不使用redux?你们可以学习如何做它的初学者项目。已经解决了,请检查我的答案…太好了!在某个时候,您需要将redux添加到您的项目中,并且您将看到此类操作将更加容易。所以越早添加redux对您越有利,除非您有不使用它的特定原因。
  return (<ProductDetails title="ProductDetails"