The match object

The match object contains information on how the <Route> path matches the current URL. It includes the url, path, isExact, and params properties.

Let's refer to one of the earlier routes where the render prop is used:

<Route    path="/user"    render={({ match }) => {        console.log(match);        return (            <div> Inside User route </div>        );    }}/>

When you try accessing the /user path, the match object's properties will have the following values:

url - '/user'path - '/user'params - {}isExact - true
  • url: A string that returns the matched portion of the URL
  • path: A string that returns the route's path string, that is, the path pattern mentioned in the <Route> component's path prop
  • params: An object containing a list of path params passed to ...

Get React Router Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.