How to convert withRouter to a React hook

The User Experience 🙃

The Implementation

The Dependencies 👶

The Hook 🎣

The Pub-Sub 📰

Subscribe and unsubscribe during the component lifecycle.
mount > effect1 ... effect2 > update > effect1 ... effect2 > unmount
If the router context has not changed, don’t subscribe or unsubscribe during updates.
When the router history changes, update this component.
On unmount, call the function returned by listen.
The effect is to subscribe and return the unsubscribe function.

Where to Go From Here? 🔮

Conclusion 🔚

Senior front end engineer /

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store