文章詳情頁
javascript - react-router 4.0版本怎么實現以前onEnter的效果
瀏覽:110日期: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. html5 - 只用CSS如何實現input框的寬度隨框里輸入的內容長短自動適應?2. 人工智能 - python 機器學習 醫療數據 怎么學3. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處4. Python爬蟲如何爬取span和span中間的內容并分別存入字典里?5. javascript - 關于css絕對定位在ios瀏覽器被橡皮筋遮擋的問題6. c++ - 請問MySQL_Connection::isReadOnly 怎么解決?7. css3 - 微信前端頁面遇到的transition過渡動畫的bug8. python - beautifulsoup獲取網頁內容的問題9. python - Django內使用filter過濾時間,只認年份不認月份是怎么回事?10. python - 能通過CAN控制一部普通的家用轎車嗎?
排行榜
