Skip to content

Commit

Permalink
(react) - fix issue where the cache infinitely loops (#2237)
Browse files Browse the repository at this point in the history
* fix issue where the cache infinitely loops

* Create selfish-singers-nail.md

* Update useQuery.ts
  • Loading branch information
JoviDeCroock authored Feb 2, 2022
1 parent 1ec08fa commit d3634b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-singers-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"urql": patch
---

fix issue where the cache infinitely loops
5 changes: 3 additions & 2 deletions packages/react-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ export function useQuery<Data = any, Variables = object>(
!result
),
subscribe(_result => {
result = _result;
if (suspense) {
cache.set(request.key, result);
}
result = _result;

if (resolve) {
resolve(result);
resolve = undefined;
Expand Down Expand Up @@ -136,10 +137,10 @@ export function useQuery<Data = any, Variables = object>(
const unsub = pipe(
source,
subscribe(_result => {
result = _result;
if (suspense) {
cache.set(request.key, result);
}
result = _result;
notify();
})
).unsubscribe;
Expand Down

0 comments on commit d3634b1

Please sign in to comment.