componentDidUpdate method
ReactJS lifecycle method that is invoked immediately after the Component
's updates are flushed to the DOM.
This method is not called for the initial render.
Use this as an opportunity to operate on the root node (DOM) when the Component
has been updated as a result
of the values of prevProps
/ prevState
.
Note: React 16 added a third parameter to componentDidUpdate
, which
is a custom value returned from getSnapshotBeforeUpdate. If a
value is not returned from getSnapshotBeforeUpdate, the snapshot
parameter in componentDidUpdate
will be null.
See: reactjs.org/docs/react-component.html#componentdidupdate
Implementation
@mustCallSuper
@override
void componentDidUpdate(Map prevProps, Map prevState, [_]) {
_transitionNotGuaranteed = false;
S tPrevState = typedStateFactory(prevState);
if (tPrevState.transitionPhase != state.transitionPhase) {
if (state.transitionPhase != TransitionPhase.SHOWING) {
// Allows the AbstractTransitionComponent to handle state changes that interrupt state
// changes waiting on transitionend events.
_cancelTransitionEventListener();
}
switch (state.transitionPhase) {
case TransitionPhase.PRE_SHOWING:
handlePreShowing();
break;
case TransitionPhase.SHOWING:
handleShowing();
break;
case TransitionPhase.HIDING:
_transitionNotGuaranteed = tPrevState.transitionPhase == TransitionPhase.SHOWING;
handleHiding();
break;
case TransitionPhase.HIDDEN:
handleHidden();
break;
case TransitionPhase.SHOWN:
handleShown();
break;
}
}
}