Route not sending correct Match object as prop
See original GitHub issueHello!
In attempting to use path params, I’m encountering an issue where the state of the <Route> shows the correct match object (with the correct path, params object) but a different match object is being passed to the render prop function. So here’s some sample code:
class App extends Component {
render() {
return (
<div>
<Switch>
<Route exact path="/" render={props => <Home {...props} {...this.props} />} />
<Route exact path="/users" render={props => <Users {...props} {...this.props} />} />
<Route exact path="/users/new" render={props => <NewUser {...props} {...this.props} />} />
<Route path="/users/:id" render={props => <User {...props} {...this.props} />} />
</Switch>
</div>
)
}
}
And some screenshots from dev tools to show you what I mean:

The User component, which should be getting the same match object from the above state as a prop:

Also note that for some reason isExact is true on the Route’s state when it should be false. Am I doing something wrong, or is this a bug of some sort? Using react-router[-dom]@4.1.1 and it’s under a react-router-redux <ConnectedRouter /> but I don’t think that’s the cause.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Route not sending correct Match object as prop #5169 - GitHub
Hello! In attempting to use path params, I'm encountering an issue where the state of the shows the correct match object (with the...
Read more >React Router don't pass value to match.props - Stack Overflow
I want to use the match object to find the props in a given url, so I can do this: function NumberHeader ({match}){...
Read more >Match - React Router: Declarative Routing for React.js
A match object contains information about how a <Route path> matched the URL. match objects contain the following properties: params - (object) Key/value...
Read more >Route - Angular
A set of routes are collected in a Routes array to define a Router configuration. The router attempts to match segments of a...
Read more >React Router v5: The Complete Guide - SitePoint
Ideally, a <Route> component should have a prop named path , and if the path name matches the current location, it gets rendered....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Be great if you could update your findings on here 😃
Any news on this? Having the same problem here…