-
Notifications
You must be signed in to change notification settings - Fork 3
fetchData() and fetchDataDeferred() behave as they should #4
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for your work on this. This solves all open issues! But, that API issue with react-router still prevents merging =( |
0491785
to
3c88f21
Compare
OK, good news, I found a way to avoid the patch in react-router. Now only the patch in redux-simple-router is required!!! |
Could you elaborate on what you changed? |
Oh sorry, yes, I amended the commit. I just used react-router.match inside history.listen, instead of using useRoutes + listenRoutes. It's essentially another way of getting the route components. |
Well, great! Thanks for all the time put into this. This is pretty damn close.. |
Dooh! I merged the other PRs first and this isn't merge-able anymore. Do you mind rebasing @mariocasciaro ? |
|
Sure, I'll try to find some time tomorrow |
3c88f21
to
d09a3ae
Compare
Should be ok to go now |
Thanks! |
let lastMatchedLocBefore; | ||
let lastMatchedLocAfter; | ||
|
||
history.listenBefore((location, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should be using match
browser-side at all. We should be using a history
that has been augmented with useRoutes
: https://github.com/rackt/react-router/blob/master/docs/API.md#useroutescreatehistory
In fact you pass routes
into createHistory
but that's not doing anything. You need to also wrap createHistory
with useRoutes
, and then the listen
signature changes: you get (error, nextState) => {}
instead, and you can just use nextState
to get all the components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but this is mainly a work-around for this: remix-run/react-router#2502
I don't think there is any practical drawback in using match
here, but probably I'm missing something?
Besides, useRoutes
can be applied only to listen
and not to listenBefore
, so unless we find another way for pulling the route components in listenBefore
(e.g. react-router gets a patch), this is the only code I got working.
Sorry for being so slow, last week was a holiday. I see a problem with how you are fetching data; I think it can be greatly simplified. Can you take a look? |
I see that you spotted some issues with the logic I implemented, but unfortunately it's the only I got working properly with the current features available in |
Sorry for being slow to respond, work is especially crazy right now. The only drawback is just complexity. If people are going to look to this as an example I want to find the best solution, and using I'd like to just play with it some more, but haven't had time. Definitely don't close this, I may merge and then make some changes after. |
I agree @jlongster about this being an example of the best solution. The ongoing issue in react-router is being discussed here now: remix-run/react-router#2614 Might be worth waiting until a resolution. |
Cool thanks for the link @quicksnap. FWIW I have a work week next week so I'm going to be super busy and not very responsive for the next week and a half. This project is a huge thing and I still don't understand all of it, so I'm at least going to be adding more simple examples to redux-simple-router but I'll keep an eye on this as well. |
@jlongster curious if there was ever a resolution for this? i'm seeing infinite loops for all routes except for '/' on version 1.0.1 |
more specifically, to trigger the loop:
and then later, when I call |
As promised
Please consider you need these patches for it to work:
https://github.com/mariocasciaro/react-router/tree/fixes (discussed here useRoutes changes the meaning of history.listen remix-run/react-router#2502)