What is a key in React ?
A “key” is a special string attribute you need to include when creating lists of elements in React. Keys are used in React to identify which items in the list are changed, updated, or deleted.
Keys are used to give an identity to the elements in the lists. It is recommended to use a string as a key that uniquely identifies the items in the list.
ReactJS Keys
React JS keys are a way of providing a unique identity to each item while creating the React JS Lists so that React can identify the element to be processed.
Table of Content
- What is a key in React ?
- Assigning keys to the list
- Issue with index as keys
- Difference between keys and props in React
- Using Keys with Components
- Incorrect usage of keys
- Correct usage of keys
- Uniqueness of Keys