Web / ReactJS Interview questions
What is a key in React?
A "key" is a special string attribute included when creating lists of elements in React. Keys are used by React to identify which items in the list are changed, updated, or deleted. In other words, we can say that keys are used to give an identity to the elements in the lists.
const numbers = [1, 2, 3, 4, 5]; const listItems = numbers.map((number) => <li key={number.toString()}> {number} </li> );
More Related questions...