question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data set to {} between re-fetches

See original GitHub issue

I created this small example to show my issue:

https://codesandbox.io/s/ovw0m6yl4z

Basically, every time I re-render the component and useQuery fetches new data, the data object is set to {} while loading is true.

How can I preserve the previously fetched data while I load new data?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
karibertilscommented, Jun 9, 2019

Any news on this ?

2reactions
trojanowskicommented, Apr 18, 2019

@FezVrasta I’m not a fan of this behavior (it’s a breaking change for me in some cases), but I’m going to fix it to make it similar to react-apollo. I prepared #134 - it uses setValues similar to how it’s done there. It should also fix #129. Unfortunately, it requires further work (currently it breaks the suspense mode).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetching queries in Apollo Client - Apollo GraphQL Docs
refetch () . When onQueryUpdated is provided, it can dynamically decide whether (and how) each query should be refetched. Returning false from onQueryUpdated ......
Read more >
Refetching Fragments with Different Data - Relay
Relay guide to refetching fragments with different data. ... The first argument is the set of variables to fetch the fragment with.
Read more >
Refetching and Loading More Data - RescriptRelay
Sometimes you'll want to refresh or refetch data in specific parts of your views without re-issuing the full query the data was originally...
Read more >
[^3.0.0] data is undefined while loading #7038 - GitHub
If firing a larger number of refetches, this actually is set to 2 ... previousData separately from result.data , as I proposed in...
Read more >
React Query Refetching Stale Data - React Tutorial 88
FREE Courses (100+ hours) - https://calcur.tech/all-in-ones Python Course - https://calcur.tech/python-courses✓ Data Structures ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found