试试这个。
基本上我通过了
navigation
来自的道具
Indprotype
组件到
Withwish
组成部分
注:我在这里假设
Indprotype型
自身接收
航行
路由器或类似设备的道具。
class Withwish extends React.Component {
ProPressed(productid){
const { navigate } = this.props.navigation;
const params = { productid };
navigate('Product', params);
}
render() {
// const { navigate } = this.props.navigation;
return (
<View style={styles.word}>
<TouchableHighlight onPress={() => this.ProPressed(this.props.id)}>
<Image source={{uri: 'https://res.cloudinary.com/hu2lcbj2n/' + this.props.image}} />
</TouchableHighlight>
</View>
);
}
}
export default class Indprotype extends React.Component {
// const { navigate } = this.props.navigation;
render() {
const items = this.state.qwerty.data;
return (
<GridView
renderItem={item => (
<Withwish
navigation = {this.props.navigation}
image = {item.p1.image}
id = {item.p1.id}
/>
)}
/>
);
}
}