在React-Native的項(xiàng)目中使用組件react-navigation進(jìn)行頁(yè)面路由管理,在A組件的componentDidMount中開(kāi)啟一個(gè)定時(shí)器,并在componentWillUnmount中進(jìn)行清除。A頁(yè)面使用this.props.navigation.navigate('B')跳轉(zhuǎn)到B頁(yè)面后,發(fā)現(xiàn)componentWillUnmount未被執(zhí)行對(duì)于該組件的問(wèn)題網(wǎng)上有如下回答: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組件中存在這樣的天然缺陷,不知各位如何應(yīng)對(duì)componentWillUnmount生命周期未調(diào)用的場(chǎng)景
React-Native中使用react-navigation,A跳轉(zhuǎn)到B時(shí)未觸發(fā)A
眼眸繁星
2019-03-08 14:11:07