在wix中反应原生导航V2如何将数据从一个屏幕传递到另一个屏幕

Anu*_*pta 1 reactjs react-native react-native-navigation

我在我们的Native Native应用程序中使用Wix反应本机导航V2.我遇到的问题是将数据从一个屏幕传递到另一个屏幕.第一个屏幕包含FLATLIST,当我选择FLATLIST行时,我需要导航并在另一个屏幕上传递行数据.

这是我的代码:

屏幕1:

此代码显示FLATLIST上的行数据(工作正常)

_renderItem = ({ item }) => {
    const text = `${item}`;
    return (
      <TouchableOpacity onPress={() => this.moveToAnotherScreen(item)}>
        <View style={styles.cardView}>
          <Text style={styles.item2}>{item.name}</Text>
          <Text style={styles.item2}>{item.Type}</Text>
          <Text style={styles.item2}>{item.mobile}</Text>

        </View>
      </TouchableOpacity>
    );
  };
Run Code Online (Sandbox Code Playgroud)

这是moveToAnotherScreen函数

moveToAnotherScreen(item) {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'ShowAnotherScreen',

      },
      passProps: {
        data: item
    }
    });
  }
Run Code Online (Sandbox Code Playgroud)

屏幕2:

componentDidMount() {

    const params  = this.props.data
    console.log('params', params);
  }
Run Code Online (Sandbox Code Playgroud)

Blu*_*ngs 8

传递道具的语法错误.试试以下

Navigation.push(this.props.componentId, {
      component: {
        name: "ShowAnotherScreen",
        passProps: {
         data: item
        }
      }
    })
Run Code Online (Sandbox Code Playgroud)

Passprops应该在里面 component