ReactBeginner#lists

Why do lists need keys?

Keys give each item a stable identity so React can match elements between renders instead of recreating them, which preserves state and avoids bugs. Array indexes make poor keys for reorderable lists.

Example
{todos.map(t => <Todo key={t.id} data={t} />)}

Related Questions

1
ReactBeginner#hooks#state

What is useState and how do you update state correctly?

Open
2
ReactIntermediate#hooks#effects

Explain useEffect and its dependency array.

Open
3
ReactIntermediate#hooks

What are the rules of hooks?

Open