Code RoomReact input loses external updates
MediumPrep Room Coding #1825

React input loses external updates

Code reviewCode quality & reviewMid–Senior~16 min

Review this React TypeScript component.

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 16 min
Mark a line and say what kind of problem it is.0 findings
1function NameField({ user }: { user?: { name?: string } }) {
2 const [name, setName] = useState(user?.name);
3 
4 return (
5 <input
6 value={name}
7 onChange={(e) => setName(e.target.value)}
8 placeholder="Your name"
9 />
10 );
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.