文章詳情頁
javascript - react-router 4.0版本怎么實現(xiàn)以前onEnter的效果
瀏覽:220日期: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
上一條:javascript - 頁面加載慢,有什么優(yōu)化方案下一條:javascript - vue 子組件有個按鈕,點擊了要改變狀態(tài),這個狀態(tài)是父組件通過接口取的,就是要動態(tài)改變接口的狀態(tài)
相關(guān)文章:
1. boot2docker無法啟動2. docker-compose中volumes的問題3. docker容器呢SSH為什么連不通呢?4. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””5. java - SSH框架中寫分頁時service層中不能注入分頁類6. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.7. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值8. 關(guān)于docker下的nginx壓力測試9. nignx - docker內(nèi)nginx 80端口被占用10. 老師,按tab鍵不起作用怎么回事
排行榜

熱門標簽
網(wǎng)公網(wǎng)安備