在React-Native的项目中使用组件react-navigation进行页面路由管理,
在A组件的componentDidMount中开启一个定时器,并在componentWillUnmount中进行清除。
A页面使用this.props.navigation.navigate('B')跳转到B页面后,发现componentWillUnmount未被执行
对于该组件的问题网上有如下回答:
Navigator uses stack to manager route. When you push a new page,
current page wont unmount, if you pop from new page to the current
page, the new page will unmount. And in other scene, if you render
some child component based on some regulation like isLoading or other,
the componentWillUnmount method will also be called when they no
longer need to be rendered.
react-navigation组件中存在这样的天然缺陷,不知各位如何应对componentWillUnmount生命周期未调用的场景
相关分类