suchen

Heim  >  Fragen und Antworten  >  Hauptteil

javascript – So erzielen Sie den vorherigen onEnter-Effekt in React-Router Version 4.0

Ich habe die offizielle Dokumentation überprüft und es scheint, dass dies nicht erwähnt wird

三叔三叔2717 Tage vor904

Antworte allen(1)Ich werde antworten

  • phpcn_u1582

    phpcn_u15822017-07-05 11:05:58

    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.

    Antwort
    0
  • StornierenAntwort