简体   繁体   English

在wix react native navigation V2中如何将数据从一个屏幕传递到另一个

[英]In wix react native navigation V2 How to pass data from one screen to another

I am using Wix react native navigation V2 in our react Native Application.我在我们的 React Native 应用程序中使用Wix React Native Navigation V2 I am getting the issue to pass data from one screen to another screen.我遇到了将数据从一个屏幕传递到另一个屏幕的问题。 First Screen contains the FLATLIST when I will select the Row of FLATLIST then I need to navigate and pass the row data at another Screen.当我选择FLATLIST的行时,第一个屏幕包含FLATLIST ,然后我需要在另一个屏幕上导航并传递行数据。

Here is my code:这是我的代码:

Screen 1:屏幕 1:

This code is showing Row data on FLATLIST(Working Fine)此代码在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>
    );
  };

This is moveToAnotherScreen function这是moveToAnotherScreen函数

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

      },
      passProps: {
        data: item
    }
    });
  }

Screen 2:屏幕 2:

componentDidMount() {

    const params  = this.props.data
    console.log('params', params);
  }

Your syntax for passing the props is wrong.您传递道具的语法是错误的。 Try below试试下面

Navigation.push(this.props.componentId, {
      component: {
        name: "ShowAnotherScreen",
        passProps: {
         data: item
        }
      }
    })

Passprops should be inside the component Passprops 应该在component内部

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

in ShowAnotherScreen在 ShowAnotherScreen

componentDidMount() {
  console.log(JSON.stringify(this.props.item))}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react native导航V2未显示屏幕标题 - react native react-navigation V2 Not showing Screen header 我如何将数据从屏幕上传递到 React Native 中的另一个? - How would I pass data from on screen to another in React Native? React Native:如何将数据从屏幕传递到另一个? - React Native: How to pass data from screen to another? 无法在React Native Navigation v2中将道具传递给其他组件 - Unable to pass props to other components in react native navigation v2 从 React-Native-Navigation v2 中删除导航栏? - Remove Navigation Bar from React-Native-Navigation v2? 如何使用 react-native 中的“this.props.navigation.goBack()”将数据传递到另一个屏幕? - How to pass data into another screen with “this.props.navigation.goBack()” in react-native? 如何在 React Native 中将数据从一个组件传递到另一个组件 - How to pass data from one component to another in react native 使用反应导航将数据从一个屏幕传递到另一个屏幕 - Passing data from one screen to another screen with react-navigation 在本机反应中将功能从一个屏幕传递到另一个屏幕 - Pass function from one screen to another in react native React Native-如何从屏幕传递到另一个屏幕? - React Native - How to pass from screen to another screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM