Code Room
Code reviewHardcr-g398
Subject State mutationLevel Senior–Staff~22 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Review this React TypeScript toggle-in-list 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.

Talk through your review
Code to reviewtsx
function Layers({ initial }: { initial: Layer[] }) {  const [layers, setLayers] = useState(initial);   const toggle = (id: string) => {    setLayers(layers.map((l) => {      if (l.id === id) l.visible = !l.visible;      return l;    }));  };   return <Panel layers={layers} onToggle={toggle} />;}
Run or narrate your approach, then ask the coach.