-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
withRouter's match prop always returning the same path. #5947
Comments
Woah, I seem to have messed thing up. Now I have a question: I want to do something similar to the test case: have a global I'm currently doing it pretty much like the test case, but match always returns |
The |
@timdorr thank you. I got it now. Going to answer my own question in case someone stumbles upon this. I created a layout. Basically, my routes now look like this: function Layout(props) {
const {
component: Component,
route,
} = props
return (
<div>
<Header />
<Component route={route} />
<Header />
</div>
)
}
function Routes() {
const layoutRender = component => route => <Layout component={component} route={route} />
return (
<Switch>
<Route
path="/projects"
render={layoutRender(Projects)}
/>
<Route
path="/"
render={layoutRender(Splash)}
/>
</Switch>
) My Hope this helps someone! |
Version
react-router-dom 4.2.2
Test Case
https://codesandbox.io/s/zw3okzz8ox
Steps to reproduce
Wrap a component with
withRouter
and then check thematch
prop.Expected Behavior
props.match.path
should update with the current path.Actual Behavior
props.match.path
always points to/
.Additional notes:
props.match.url
behaves exactly the same: it always points to/
. The only property that seems to change correctly isisExact
, which is not of much use.The text was updated successfully, but these errors were encountered: