React Answers

How to access ‘this.props.match.params’ along with other props with React Router?

Spread the love

To access ‘this.props.match.params’ along with other props with React Router, we pass in the matchProps from the render prop function into our component.

For instance, we write

  render={(matchProps) => (

to add the Route component and pass in matchProps to the ChampionDetails component.

Now ChampionDetails has access to all the properties of matchProps as props.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *