-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Dependant queries #1413
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
This is purely because we use safe side effects as opposed to mutating or altering state during a render. If we were to do the opposite, you’d get some really really strange behavior, especially if and when you start using suspense. Curious why this is an issue for you? |
Well, with something like this you end up seeing the loader flash, but perhaps there is some easy workaround that im missing?
Also, I believe it used to work as the expected behaviour I presented. |
Hmm. I’ll take a deeper look. |
I checked against v2.26.4, it prints:
(success loading is printed twice). also, every window re-focus prints v3.2.0 prints, as OP says:
every window re-focus also prints |
The returned values from the hooks in v3 are read from the component state instead of directly from the observer. This will make sure no state update is skipped. So when using a hook, you can be sure you will be notified of all changes. I guess this could be important when dealing with side effects. The downside of this though, is that no state update is skipped ;) When rendering, the observer might already contain a newer state, which could be used instead of the component state, but any states in between will then never be rendered. |
so how would we go about |
I guess the only way to prevent this is to immediately returning the updated value instead of waiting for the state to update. Let me see what I can do here. |
Cheers guys! |
Describe the bug
Dependant queries leave an in between state after the first query has succeeded where the first query has a successful status and the following query is still in idle.
To Reproduce
Expected behavior
I expect there to be no inbetween state and for queryB to go into a loading state as soon as queryA has succeeded. Expected console log would be:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: