Home
← All questions

Reconciliation, keys, and list rendering in React

MediumPremiumReact

Asked at Meta · Google · Microsoft

React interview practice: Explain how React diffs lists, why index keys are dangerous, and reconciliation rules.

Answer

During reconciliation React compares the new element tree to the previous one:

  1. Different element types → tear down old subtree, mount new one.
  2. Same type, same key → update props in place, preserve state/DOM where possible.
  3. Lists → keys tell React which item moved vs was added/removed.

Anti-pattern: using array index as key when items can reorder, insert, or delete — causes wrong component state, skipped updates, and poor performance.

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium