mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 16:03:20 +00:00
fix(diff): keep renderedIndicesRef pure during render
React Doctor blocks ref mutation during render; sync the on-screen section set in a layout effect instead so static analysis can pass.
This commit is contained in:
@@ -902,8 +902,10 @@ export default function CombinedDiffViewer({
|
||||
})
|
||||
const combinedDiffTotalSize = virtualizer.getTotalSize()
|
||||
const combinedDiffVirtualItems = virtualizer.getVirtualItems()
|
||||
// Why: retrySection needs the on-screen set without taking the virtualizer as a dep.
|
||||
renderedIndicesRef.current = new Set(combinedDiffVirtualItems.map((item) => item.index))
|
||||
// Why: keep render pure (React Doctor); retrySection still needs the on-screen set without the virtualizer as a dep.
|
||||
useLayoutEffect(() => {
|
||||
renderedIndicesRef.current = new Set(combinedDiffVirtualItems.map((item) => item.index))
|
||||
}, [combinedDiffVirtualItems])
|
||||
const getCombinedDiffSectionKey = useCallback((section: DiffSection): string => section.key, [])
|
||||
const getCombinedDiffSectionElementKey = useCallback(
|
||||
(element: Element): string | null =>
|
||||
|
||||
Reference in New Issue
Block a user