Code RoomShallow copy nested state
HardPrep Room Coding #1816

Shallow copy nested state

Code reviewCode quality & reviewSenior–Staff~24 min

Review this React TypeScript reducer-free updater.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 24 min
Mark a line and say what kind of problem it is.0 findings
1function Settings() {
2 const [config, setConfig] = useState({ theme: { color: 'light', font: 'sans' } });
3 
4 const setColor = (color: string) => {
5 const next = { ...config };
6 next.theme.color = color;
7 setConfig(next);
8 };
9 
10 return <ThemePreview theme={config.theme} />;
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.