繁体   English   中英

使用Navigation.push(来自wix的本地导航v2)我没有在目标组件中获取道具。 我如何访问道具?

[英]With Navigation.push (v2 of react native navigation from wix) I am not getting props in destination component. How do I access props?

我使用Navigation.push传递道具,然后尝试获取目标组件中的下面的道具。

尝试的结果:我得到'未定义的图像'

我在react-native-app中使用redux,redux工作正常,我可以在其他组件中看到我的数据。 但是当我按下并尝试访问目标组件中的道具时,我什么也看不到。

当我只是console.log的道具时,我得到的就是在placeDetail组件中的componentId和rootTag。 我究竟做错了什么?

 Navigation.push(this.props.componentId, { component: { name: "navigation.playground.PlaceDetailScreen" }, options: { topBar: { title: { text: selPlace.name } } }, passProps: { selectedPlace: selPlace } }); 

 const placeDetail = props => { console.log(props) return ( <View style={styles.container}> <View> <Image source={props.navigationselectedPlace.image} style={styles.placeImage} /> <Text style={styles.placeName}>{props.selectedPlace.name}</Text> </View> <View> <TouchableOpacity onPress={props.onItemDeleted}> <View style={styles.deleteButton}> <Icon size={30} name="ios-trash" color="red" /> </View> </TouchableOpacity> </View> </View> ); }; 

在Navigation.push里面,一切都应该在组件对象中。

像这样:

您目前拥有选项并在组件外部传递道具。

 Navigation.push(this.props.componentId, { component: { name: 'example.PushedScreen', passProps: { text: 'Pushed screen' }, options: { topBar: { title: { text: 'Pushed screen title' } } } } }); 

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM