Skip to content
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

Proposal: react-router-mobx #4785

Closed
maxdeviant opened this issue Mar 20, 2017 · 4 comments
Closed

Proposal: react-router-mobx #4785

maxdeviant opened this issue Mar 20, 2017 · 4 comments

Comments

@maxdeviant
Copy link
Contributor

During an attempted upgrade to react-router v4 in a MobX codebase, I encountered the blocked updates issue. Obviously this is a bit of a deal breaker, since it would mean wide-sweeping changes to make all of the observers aware of location changes.

I have seen it hinted at in a couple of places that react-router-redux has a way around this in v5. I think it would be beneficial if this same fix/methodology could be brought to those of us using MobX.

I can see about getting a PR ready once react-router-redux v5 gets closer to release, but I just wanted to get this idea out there.

I think having first-class MobX support like we have for Redux would go a long way in bringing the community together around the coolest router 😎

@maxdeviant
Copy link
Contributor Author

There is also some good discussion over in the Redux Integration (#4668) PR which may be relevant.

@agundermann
Copy link
Contributor

agundermann commented Mar 20, 2017

As far as I can tell, the primary goal of react-router-redux is not to work around the blocked updates issue, but to integrate react-router with redux by syncing the router location with the redux store. I don't know mobx enough to say if that's possible/practical there, too. But if you're just concerned about the blocked updates, you don't really need an extra library for this; you can simply compose the HoCs/decorators yourself:

// observerWithRouteProps.js
import {observer} from 'mobx-react';
import {withRouter} from 'react-router';

export default Component => withRouter(observer(Component));

And then just use that function instead of observer from react-mobx. This should work with all HoCs/decorators that respect the prop updates of the component.

@timdorr
Copy link
Member

timdorr commented Mar 20, 2017

react-router-redux does nothing with connected components or blocked updates. It's simply for synchronization of location into state.

If you mean the changes on react-redux, that is a separate thing were doing here: reduxjs/react-redux#625

Anything that gets around blocked updates is either something to be solved by the library that's blocking, or is something we would solve in a much more generic implementation than just for MobX's use.

@timdorr timdorr closed this as completed Mar 20, 2017
@maxdeviant
Copy link
Contributor Author

@timdorr Thanks for the info!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants