A user profile editor shows a name and email. Editing the name should update it on screen. The name never updates even though the input changes.
Type in the Name field — the displayed name below the inputs never changes. The value in the input itself updates but the profile summary stays stale.
Look at what handleNameChange passes to setProfile.
Look at what handleNameChange passes to setProfile.
Why this fixes it
handleNameChange wrote directly to profile.name before passing the same object reference to setProfile — because the reference never changed, React's shallow equality check saw identical old and new state and skipped the re-render entirely, leaving the paragraph frozen. Replacing that with setProfile({ ...profile, name: e.target.value }) creates a new object with a new memory address on every change. React detects the reference change, schedules a re-render, and the Name: paragraph updates to reflect the current input value.