Skip to content

Commit 0159f90

Browse files
Copilothotlong
andcommitted
Address code review: stabilize useMemo dependency array
- Replace ternary in useMemo deps with computed stableKey variable Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 84565fc commit 0159f90

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

apps/console/src/components/ViewConfigPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ export function ViewConfigPanel({ open, onClose, mode = 'edit', activeView, obje
8282
// Stabilize source reference: only change when view ID changes.
8383
// This prevents useConfigDraft from resetting on every parent re-render
8484
// (same behavior as original useEffect with [activeView.id] dependency).
85+
const stableKey = mode === 'create' ? 'create' : activeView.id;
8586
const stableActiveView = useMemo(
8687
() => ({ ...activeView }),
87-
[mode === 'create' ? 'create' : activeView.id], // eslint-disable-line react-hooks/exhaustive-deps
88+
[stableKey], // eslint-disable-line react-hooks/exhaustive-deps
8889
);
8990
const effectiveActiveView = mode === 'create' ? defaultNewView : stableActiveView;
9091

0 commit comments

Comments
 (0)