Skip to content

Commit

Permalink
fix(presentation): avoid duplicate key warning (#8319)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Jan 20, 2025
1 parent cbbebd5 commit 48f3e68
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 48f3e68

Please sign in to comment.