猿问

react-router 4.0版本怎么实现以前onEnter的效果

查看了官方文档,好像并没有说到这个

胡说叔叔
浏览 967回答 1
1回答

MM们

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.
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答