-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Remove context.location #3961
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
Comments
Some helper like 'withLocation' will be great for start |
3.0 will get around this by using this neat mixin: https://github.com/ReactTraining/react-router/blob/v3/modules/ContextUtils.js You can probably do that without a mixin format. I know @taion was going to split that code out to a separate package, since it's something that affects a lot of context-using libraries. Not sure what the status of that effort is, but might want to check in with him to see if he's still planning on it. |
Will this subscription apply to every I think that it might make sense to preserve componentWillMount() {
if ( this.props.listen ) {
// don't need state anymore
this.context.router.addChangeListener(() => { this.forceUpdate(); });
}
}
<Link listen to='/faq' activeClassName='active'>FAQ</Link> The |
@pshrmn We don't want to expose internal concerns to the end user. Adding a listener isn't a big deal, as React will batch together any concurrent |
You're right though, @pshrmn. The only |
Done in ce59676 |
Are there any plans to export the |
@jochenberger you can do this at the moment:
But I agree, it would be good to have this exported from |
I'm in AMD environment, so unfortunately, I'm limited to what's exported there. |
Right now v4 uses
context.location
to pass the currentlocation
down to<Link>
s. However, context isn't great for communicating state updates becauseshouldComponentUpdate
does not take context into account. This means that people who are using sCU (i.e. everyone using Redux) won't get these changes.Instead, the router should rely on a listener/subscription mechanism. We can introduce this pretty easily using something like:
Note that
addChangeListener
is not the same ashistory.listen
because it needs to fire once immediately.The text was updated successfully, but these errors were encountered: