[英]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.