I was using the componentWillReceiveProps
lifecycle event to enable or disable transition to the next page. Now that this event is changed to UNSAFE_componentWillReceiveProps
, I feel like I shouldn't use it anymore, however I couldn't find an obvious replacement for it.
The location of the component comes from props.location.pathname
, so I'd need an event, where I can access both the previous and next props and then set the initial appearance of the component depending on if there should be transition or not, however:
getDerivedStateFromProps
only has access to the previous props.shouldComponentUpdate
should be used for telling the component if it should update or not, which is not what we want, so it's out.render
doesn't have the previous props.getSnapshotBeforeUpdate
passes the parameter tocomponentDidUpdate
, at which point the component is already rendered, so I can't set the initial apprearance.
I guess I could save the previous pathname and use that the next time in render
, but this doesn't seem like an elegant solution. What is the best practice in this situation?