ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

How can you reset a component's internal state from the parent?

Quick answer

Change its key prop. A new key makes React treat it as a brand-new element, unmounting the old one and remounting fresh.

In detail

Because reconciliation matches elements by type and key, changing the key forces React to discard the old instance (and its state) and create a new one. This is the idiomatic way to reset a form or component when a meaningful identifier changes, without manually clearing every field.

// remount (clear all internal state) when the user changes
<ProfileForm key={userId} user={user} />

Why interviewers ask this: A clever question that tests deep reconciliation understanding.

This is 1 of 118+ questions in the React Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the React Interview Kit → ₹399

Full kit

React Interview Kit · ₹399

Get it →