Lists and keys
Overview of Lists and keys – All React component pass a special attribute called the key . React key is uniquely identifier. React element identity is critical for performance and minimizing DOM manipulation: for example, if the first element in a list of thousands should no longer be rendered.
Key :- Key is special attribute and help to uniquely identify which items have changed, added and removed. Best way to take a key is to use a string that uniquely identifies a list item as like key =”val”.
const str= ['a', 'b', 'c', 'd', 'e'];
const listItems = str.map((str) =>
Create Content elements dynamically with unique index. In above example map function create five elements from our str array. Since the key value we needs to be unique for every element, we are assigning str as a key for each created element.