-
Notifications
You must be signed in to change notification settings - Fork 108
fix: show previous data while loading new one #121
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
Conversation
50b70fa
to
d4b5225
Compare
src/useQuery.ts
Outdated
@@ -96,6 +96,8 @@ export function useQuery< | |||
? 'cache-first' | |||
: actualCachePolicy; | |||
|
|||
const lastResult = useRef(); |
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.
we use this to be able to reference the actual previously returned data, we can't use observableQuery.getLastResult()
because observableQuery
may get invalidated and return null
d4b5225
to
5e7f47b
Compare
I don't know why I'm getting the two type errors reported by CI, the code uses the same |
Thanks for submitting, this is broken compared to vanilla apollo React and needs a fix! I suspect the original {}).data code works because it can never return null (so we never get to the right-hand side of the || and there's always .data). I.e. the "|| {}" is never called. It also looks like you need to set a template on your useRef call so the compiler knows that you will be setting null OR the result type. |
Closing in favour of #134 |
…hat previous value of `data` is shown while loading new one and `networkStatus` should have a correct value in that case BREAKING CHANGE: previous value of `data` is shown while loading new one Closes trojanowski#117 Closes trojanowski#121 Closes trojanowski#129
This PR should fix the issue reported in #117