2017-06-16 62 views
2

我有我的路由器這樣的陣營掛載/卸載事件

<Route component={Home} exact path="/" /> 
<Route component={ChannelScreen} path="/channel/:channelId" /> 

首頁和ChannelScreen組件包含播放器組件。 所以當我改變頁面時,每次都會創建一個新玩家。但是,在componentWillUnmount之前調用Player componentDidMount事件。 玩家組件在銷燬另一個之前被重新創建。

不應該在創建新組件之前啓動componentWillUnmount嗎?

+0

大聲笑,有趣的:d – croraf

+0

我不知道答案,但你可以從這個https://github.com/facebook/react-native/commit/5eb3ab3522bd1d46fb4f8471c8207f1e0bc2cc25 – Yozi

+0

你有反應,路由器哪個版本開始研究? – croraf

回答

0

我做了一個測試,這通常不是真的,componentWillUnmount在componentWillMount之前調用。你的應用程序中有一些錯誤。