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.
This commit is contained in:
Jinjing
2026-08-06 19:00:19 -07:00
parent b3d984da40
commit e43e85a138
@@ -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) {