-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Provide a previousData property in useQuery/useLazyQuery results #7082
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hwillson
force-pushed
the
issue-6603
branch
from
September 27, 2020 00:41
b211f4b
to
ea6ce37
Compare
Alongside their returned `data` property, `useQuery` and `useLazyQuery` now also return a `previousData` property. Before a new `data` value is set, its current value is stored in `previousData`. This allows more fine-grained control over component loading states, where developers might want to leverage previous data until new data has fully loaded. Fixes #6603
hwillson
force-pushed
the
issue-6603
branch
from
September 27, 2020 00:43
ea6ce37
to
ce4a9aa
Compare
benjamn
approved these changes
Sep 28, 2020
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.
@hwillson Thanks for this!
I made a few tweaks, but the main thing was to let result.previousData
persist across multiple results. See the test I added for an example where result.data
can be undefined twice in a row.
Great catch @benjamn - thanks for finishing this up! |
This was referenced Sep 28, 2020
2 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alongside their returned
data
property,useQuery
anduseLazyQuery
now also return apreviousData
property. Before a newdata
value is set, its current value is stored inpreviousData
. This allows more fine-grained control over component loading states, where developers might want to leverage previous data until new data has fully loaded.@benjamn just a heads up that I did look into moving the
previousData
handling up the chain into the ACcore
itself. The amount of work needed to get this functionality in place would have been more substantial however (as thelastResult
tracking we’re doing inObservableQuery
doesn’t quite line up with what we’re looking for here), so I’ve left it in the React layer for now (where we were already trackingpreviousData
, but just not exposing it). This should address most of the oustanding issues around this functionality, and we can always consider this a stepping stone. Changing how this works internally in the future will be hidden fromuseQuery
/useLazyQuery
consumers. Thanks!Fixes #6603