【发布时间】:2021-02-02 12:10:13
【问题描述】:
所以我有这个显示产品详细信息的屏幕,它像模板一样工作,因为只有来自导航参数的数据发生变化,我遇到问题是因为没有重新加载,返回并再次安装时它工作正常,那不是这里的情况,因为我在同一个屏幕上显示了相关产品,我需要一种方法来重新加载当前路线或更新状态
我已经用 console.log 检查过,第二次点击没有任何显示
constructor (props) {
super(props)
this.state = {
product: this.props.route.params.product,
id: this.props.route.params.product.id,
}
}
导航到我在屏幕本身或其他路线上使用的路线
viewProduct = (product) => {
this.props.navigation.navigate('SingleProduct', { product: product })
}
我在componentDidMount 和UNSAFE_componentWillReceiveProps 中都尝试过 setState,但结果仅在再次点击后才会显示
【问题讨论】:
-
你能告诉我 react-navigation 和 react-native 的版本吗?
-
这能回答你的问题吗? Refresh previous screen on goBack()
标签: javascript reactjs react-native