-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 error, if used withOUT router #4292
Comments
We should probably just return the wrapped component: if (!router) return <WrappedComponent {...this.props} /> A PR for this would be appreciated! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.0
Steps to reproduce
use
withRouter
without a Router ;) (Rendering stuff in styleguidist)this.props.router
is used only in action handlersExpected Behavior
The component should at least render.
Actual Behavior
Get an error message:
TypeError: Cannot read property 'params' of undefined
Unfortunately, I am unable to debug in styleguidist quickly, but I think the error is coming from here:
https:/ReactTraining/react-router/blob/6eeb7ad358f987520f5b519e48bdd31f725cbade/modules/withRouter.js#L32
Maybe a quick and dirty fix on Line 31 would be enough:
const router = this.props.router || this.context.router || {}
The text was updated successfully, but these errors were encountered: