Search⌘ K

Connecting Components with a Router Using Higher-order Component

Understand how to use the withRouter higher-order component to grant React components access to routing props like history, location, and match. Learn scenarios for its use, including redirecting pages, avoiding update blocking in optimized components, and managing React Router interactions alongside Redux.

We'll cover the following...

a Each component used as a component prop in a Router element is automatically passed the router props history, location, and match. Sometimes, however, it’s useful to be able to access Router functionality in components that are not using a direct route—for example, to redirect to another page using history.push().

The withRouter higher-order component

React Router provides a withRouter higher-order ...