-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Closed
Labels
feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yetUsed to close PRs that haven't gone through/been accepted the Proposal process yet
Milestone
Description
When React documented context we were like "YAY! we can just tell everybody to use context for the router." But we were probably over-confident in its stability and people's comfort with that API. I think we can wrap up everything into a higher-order component like:
import { withRouter } from 'react-router'
withRouter(SomeComponent)
// in SomeComponent
this.props.router
- We'll shield our users from context changes in the future and save much JSF
- We won't have to document the infinite ways that React + JavaScript + Babel can get router from context (Expanded API docs for
context.router
#3346)
We could probably even provide a this.props.confirmOnLeaveRoute
shortcut like the Lifecycle
mixin used to provide.
Whose with me?
(yes, this has been talked about before, thanks to those who tried to get this in before :)
Potential names:
connectRouter
like Redux. Seems weird to me, not sure if that name is about connecting to the store, or to the data in the store.injectRouter
like React Intl. I'm also iffy on this since it's not technically "injection", you're asking for it, not injecting it.- I like
withRouter
but whatever ... is there a community name for this yet? If not, can we start lobbying for this one?
taion, sergiodxa, vcarl, timdorr, markdalgleish and 22 more
Metadata
Metadata
Assignees
Labels
feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yetUsed to close PRs that haven't gone through/been accepted the Proposal process yet