文章詳情頁
javascript - react-router 4.0版本怎么實現以前onEnter的效果
瀏覽:139日期:2023-02-18 15:49:01
問題描述
查看了官方文檔,好像并沒有說到這個
問題解答
回答1:React Router v3 provides onEnter, onUpdate, and onLeave methods. These were essentially recreating React’s lifecycle methods.
With v4, you should use the lifecycle methods of the component rendered by a <Route>. Instead of onEnter, you would use componentDidMount or componentWillMount. Where you would use onUpdate, you can use componentDidUpdate or componentWillUpdate (or possibly componentWillReceiveProps). onLeave can be replaced with componentWillUnmount.
標簽:
JavaScript
相關文章:
1. mysql - 記得以前在哪里看過一個估算時間的網站2. python中merge后文件莫名變得非常大3. 希望講講異常處理4. css3 - 純css實現點擊特效5. docker start -a dockername 老是卡住,什么情況?6. javascript - 關于<a>元素與<input>元素的JS事件運行問題7. java - 為什么第一個線程已經釋放了鎖,第二個線程卻不行?8. css3 - [CSS] 動畫效果 3D翻轉bug9. javascript - 如何將一個div始終固定在某個位置;無論屏幕和分辨率怎么變化;div位置始終不變10. 大家好,我想請問一下怎么做搜索欄能夠搜索到自己網站的內容。
排行榜
