Skip to content

Commit

Permalink
Add explainer comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 26, 2024
1 parent 673245d commit 02bdd31
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/react/hooks/useFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ function _useFragment<TData = any, TVars = OperationVariables>(
let lastTimeout = 0;
const subscription = cache.watchFragment(stableOptions).subscribe({
next: (result) => {
// Since `next` is called async by zen-observable, we want to avoid
// unnecessarily rerendering this hook for the initial result
// emitted from watchFragment which should be equal to
// `currentDiff`.
if (equal(result, currentDiff)) return;
resultRef.current = result;
// If we get another update before we've re-rendered, bail out of
Expand Down

0 comments on commit 02bdd31

Please sign in to comment.