文章詳情頁
javascript - react-router 4.0版本怎么實現以前onEnter的效果
瀏覽:111日期: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. javascript - 請問 chrome 為什么會重復加載圖片資源?2. (python)關于如何做到按win+R再輸入文件文件名就可以運行?3. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處4. python - 能通過CAN控制一部普通的家用轎車嗎?5. javascript - react input file6. javascript - 請教如何獲取百度貼吧新增的兩個加密參數7. css3 - 微信前端頁面遇到的transition過渡動畫的bug8. Python爬蟲如何爬取span和span中間的內容并分別存入字典里?9. html5 - 只用CSS如何實現input框的寬度隨框里輸入的內容長短自動適應?10. javascript - 關于css絕對定位在ios瀏覽器被橡皮筋遮擋的問題
排行榜
