-
Notifications
You must be signed in to change notification settings - Fork 48
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
Router Context is Swallowed #25
Comments
Firstly the short-term solution: definitely. It seems many people are running in to this. The long-term solution is a bit tricky. I would agree that looking into how (or if) I can try to find time in the next few days to look at Thanks |
Done a bit of research, and I think A relevant link: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md |
I have similar problem or even the same, not sure. I tried to wrap every observer with wihtRouter but it doesnt help.
Thats the decorator i tried to use. |
If the component that renders the |
It is.. although i pinpointed problem to https://www.npmjs.com/package/lazy-route . If i use it with Switch it doesnt update even with withRouter, otherwise its fine. |
after use sample project. one can help me out? sorry, I am using |
Does someone have a complete working example of this workaround? |
@clementdevosmc I have made a boilerplate. You can have a try. |
@clementdevosmc Notice the |
Correct me if I am wrong, but it seems like the short term solution proposed by @dleavitt to just add a couple of sentences to the readme to describe this problem has not been implemented, nothing has been added to the readme about this issue since June 2017, and the current readme keeps claiming that the package is a functional solution for react-router v4. Well, it is not. |
Firstly: let's keep the sass to a minimum. There hasn't been activity on this issue for a while now and Secondly: I have now updated the README with some information about this issue, with relevant links. The React guys are currently rewriting the context API, and should be released soon. This might affect (and hopefully fix) this issue, so we can revisit it then. Closing this for now. |
👍 |
I am here to resurrect #19 and #16, for which I apologize.
I believe the current state of things is that mobx (and mobx-react-router) don't really work out of the box with react-router v4.
Cause:
observer
components use a customizedshouldComponentUpdate
that pays attention to the mobx context but not the context that react-router needs.Here's a repro:
Current workaround:
Users of this lib should wrap
withRouter
around every observer in their app.Solutions:
Though this isn't
mobx-react-router
's fault (remix-run/react-router#4781, etc, etc) it does appear that this library owns the space at the intersection of mobx and react-router and is therefore in the best position to bundle a fix or workaround.Short-term solution: This should be called out prominently in the readme. It's relevant to ~100% of people who use this lib (I think?)
Longer-term solutions: A fix or workaround should be integrated into this lib if possible. I think it is possible! Anything is possible, right? Here are some potential approaches:
react-router-redux
does. Assuming it has this problem solved, which I haven't verified.syncHistoryWithStore
, somehow turn the history attributes that react-router uses intoobservable
s. If that's a thing.Route
orNavLink
, but at least you don't have to wrap every singleobserver
inwithRouter
.observer
as part of this lib. This at least provides a solution out of the box and gets people like me to stop writing our own dubious one-offs.Happy to submit a PR for the README or to look into options 3/4 if you agree with the above.
Thanks!
Daniel
The text was updated successfully, but these errors were encountered: