在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 currentpage, the new page will unmount. And in other scene, if you rendersome child component based on some regulation like isLoading or other,the componentWillUnmount method will also be called when they nolonger need to be rendered.react-navigation組件中存在這樣的天然缺陷,不知各位如何應對componentWillUnmount生命周期未調用的場景
React-Native中使用react-navigation,A跳轉到B時未觸發A
眼眸繁星
2019-03-08 14:11:07