RN使用
createBottomTabNavigator
创建底部导航栏时,只会在第一次创建时调用 componentDidMount 钩子,当跳转到另一个页面,点击返回键再次返回到此页面时不会再次调用,但我们往往需要在返回此页面后重新执行获取数据等方法函数。
componentDidMount() {
this._navListener = this.props.navigation.addListener('didFocus', () => {
this.getData();
});
}
componentWillUnmount() {
this._navListener.remove();
}
监听路由,即使页面没有被重新渲染,当路由 didFocus
时,也会执行回调函数。
react-navigation createBottomTabNavigator 刷新问题
原文:https://www.cnblogs.com/xiongxiaolong/p/10713078.html