What you need to know

Keys help React preserve the identity of each rendered item between updates. Unstable keys can cause state to appear on the wrong row or inputs to lose their value when a list changes.

How to apply it

Use a database ID or another stable unique identifier from the item. For static lists that never reorder, an index can work, but the key should still identify the item consistently.

Common mistake to avoid

Do not generate a random key during render. That makes every item look new and can force unnecessary remounts.