ReactReact Keys

Keys help React identify which items have changed, are added, or are removed. They should be unique and stable across re-renders.

Keys are required when rendering lists of elements.

const items = ['Apple', 'Banana', 'Cherry'];

const listItems = items.map((item, index) => (
  <li key={index}>{item}</li>
));