Why must each item in a React list have a unique ‘key’ prop?

React Developer Easy

React Developer — Easy

Why must each item in a React list have a unique ‘key’ prop?

Key points

  • The 'key' prop helps React optimize list rendering
  • It prevents unnecessary re-renders of list items
  • Each key should be unique within the list
  • React uses keys to track which items have changed

Ready to go further?

Related questions