Skip to content

Commit

Permalink
fix(presentation): avoid duplicate key warning
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jan 17, 2025
1 parent b53b164 commit b9b83e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/sanity/src/presentation/loader/LoaderQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@ const Turbo = memo(function Turbo(props: TurboProps) {
}
}
const nextBatchSlice = [...nextBatch].slice(0, LIVE_QUERY_CACHE_BATCH_SIZE)
if (nextBatchSlice.length === 0) return
setBatch((prevBatch) => [...prevBatch.slice(-LIVE_QUERY_CACHE_BATCH_SIZE), nextBatchSlice])
if (nextBatchSlice.length === 0) return undefined
const raf = requestAnimationFrame(() =>
// eslint-disable-next-line max-nested-callbacks
setBatch((prevBatch) => [...prevBatch.slice(-LIVE_QUERY_CACHE_BATCH_SIZE), nextBatchSlice]),
)
return () => cancelAnimationFrame(raf)
}, [batch, cache, turboIds])

// Use the same listen instance and patch documents as they come in
Expand Down

0 comments on commit b9b83e4

Please sign in to comment.