Skip to content

Commit 357946e

Browse files
Anders Hafreagerclaude
andcommitted
refactor: tighten useEffect dependency array for showSimulationBox sync
Use the functional update form of setRenderSettings so the effect only needs renderSettings.showSimulationBox (not the full renderSettings object) in its dependency array. This avoids re-running the effect on unrelated renderSettings changes and eliminates the stale-closure risk of spreading a captured renderSettings snapshot. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a415ce commit 357946e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/containers/View.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,15 @@ const View = ({ visible, isEmbeddedMode = false }: ViewProps) => {
409409
isEmbeddedMode &&
410410
renderSettings.showSimulationBox !== embedConfig.showSimulationBox
411411
) {
412-
setRenderSettings({
413-
...renderSettings,
412+
setRenderSettings((prev) => ({
413+
...prev,
414414
showSimulationBox: embedConfig.showSimulationBox,
415-
});
415+
}));
416416
}
417417
}, [
418418
isEmbeddedMode,
419419
embedConfig.showSimulationBox,
420-
renderSettings,
420+
renderSettings.showSimulationBox,
421421
setRenderSettings,
422422
]);
423423

0 commit comments

Comments
 (0)