我开发了一个应用程序使用导航抽屉。导航屏幕使用导航抽屉。但导航时我不会刷新屏幕。我解决了这个问题
在componentDidMount()
中添加以下代码
componentDidMount() {
this.subs = this.props.navigation.addListener("didFocus", () =>
//Your logic, this listener will call when you open the class every time
);
}
并且不记得在componentWillUnmount()
删除监听器,
componentWillUnmount() {
this.subs.remove();
}