简体   繁体   English

背面的 React Native Navigation 刷新列表屏幕

[英]React Native Navigation Refresh List Screen on back

React Native Navigation Refresh List Screen on back:背面的 React Native Navigation 刷新列表屏幕:

this.props.navigation.navigate('Order List', {
  order_id: this.state.order_id,
  order_status: this.state.od_status,
})

What you want to achive isn't clear, but if want to modify your list of data when going back to your previous screen you could simply use useEffect and modify your list in there.您想要实现的目标尚不清楚,但如果想在返回上一个屏幕时修改您的数据列表,您可以简单地使用useEffect并在其中修改您的列表。

Note: Your list has to be stored in a local state otherwise the screen wouldn't re-render when updating the list and youl would see no changes on your screen.注意:您的列表必须存储在本地 state 中,否则更新列表时屏幕不会重新渲染,您将在屏幕上看到没有任何变化。

better description of the problem would be helpful, but this is general solution for class based components:更好地描述问题会有所帮助,但这是基于 class 的组件的一般解决方案:

componentDidMount() {
    this._unsubscribe = this.props.navigation.addListener('focus', () => {
        this.loadDataFunction();
    }
}

componentWillUnmount() {
    this._unsubscribe();
}

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

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