-
Notifications
You must be signed in to change notification settings - Fork 162
Use Public API for React-Router instead of Private Context #248
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
Conversation
* IndexLinkContainer: * Wrapped `withRouter` as default export, * Now exports original component separately * LinkContainer: * Wrapped `withRouter` as default export, * Now exports original component separately * `contextTypes` validation has been removed * `propTypes` now expects `history` object, as it is expected to be wrapped `withRouter` * `this.context.router.history` references replaced with `this.props.history` * Tests updated to deal with wrapped component vs real component references * git ignore updates
* Made `history` propType required * Added propTypes: `location`, `match`, `staticContext`, since `withRouter` will provide them * Updated `render()` to strip props (`location`, `match`, `staticContext`) from children
This is great, thanks! |
For curiosity, when can we expect a new release with this change? |
I agree. LinkContainer is broken for anyone upgrading to react-router 5.x, so breadcrumbs stop working without hacky solutions that lead to nested anchors and validateDOMnesting warnings. |
+1 to a release. Also feeling the pain as I'm working with react-router v5. @v12 any timeline? |
A workaround is available here #250 |
@v12 are you |
released in v0.25.0 |
@taion thank you! |
@v12 done |
Per: https://github.com/ReactTraining/react-router/releases/tag/v4.4.0-beta.0
Since react-router-bootstrap uses the forbidden contextTypes, this PR addresses that.
In short, LinkContainer is now exported by default, wrapped by
withRouter
. This exposeshistory
and such directly as a property on LinkContainer.Additionally, the original unwrapped LinkContainer class is exported, if desired.
Summary of changes:
withRouter
as default export,withRouter
as default export,contextTypes
validation has been removedpropTypes
now expectshistory
object (required), as it is expected to be wrappedwithRouter
location
,match
,staticContext
, sincewithRouter
will provide themthis.context.router.history
references replaced withthis.props.history
render()
to strip props (location
,match
,staticContext
) from childrenFixes #237