From e43e85a1383b6fd7fcd649f411f20684e5ba301b Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 6 Aug 2026 19:00:19 -0700 Subject: [PATCH] fix(diff): avoid render-time ref mutation in section model lifecycle React Doctor fails static analysis when refs are written during render. Move the disposer ref sync into an effect so the stable callback-ref still disposes with the latest model paths. --- .../components/editor/use-diff-section-model-lifecycle.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/editor/use-diff-section-model-lifecycle.ts b/src/renderer/src/components/editor/use-diff-section-model-lifecycle.ts index 6770e39ebdc..5d8c901c367 100644 --- a/src/renderer/src/components/editor/use-diff-section-model-lifecycle.ts +++ b/src/renderer/src/components/editor/use-diff-section-model-lifecycle.ts @@ -20,7 +20,10 @@ export function useDiffSectionModelLifecycle(params: { }, 0) }, [params.modelPathBase]) const disposeDiffModelsRef = useRef(disposeDiffModels) - disposeDiffModelsRef.current = disposeDiffModels + // Keep callback-ref dispose path on the latest disposer without render-time mutation. + useEffect(() => { + disposeDiffModelsRef.current = disposeDiffModels + }, [disposeDiffModels]) const setSectionRootNode = useCallback((node: HTMLDivElement | null): void => { if (node) {