Chapter 6 · Example 7 · Deep dive into diffing and reconciliation

Force reuse with shared key

Putting the same key on inputs rendered in different array positions makes React reuse one instance across the switch, preserving its state and DOM.

Loading live editor…