-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

React Interview Guide
By :

Keys help you control component or element instances. They play a major role in deciding whether the element needs to be re-rendered or not in a list of elements. Hence, every developer should have an idea about the importance of a key prop.
A key is a special attribute that you need to include when creating a list of elements in a component. This key prop helps React identify which elements have changed and been added or removed. In other words, it helps you retain a unique identity of the elements or among the siblings in the list even after the elements have been modified.
Even if you don’t supply a key prop, the list can render the content to the browser successfully, but with a warning message logged in the console, as shown here:
Warning: Each child in an array or iterator should have a unique "key" prop...