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”.

Using Keys

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.

Categories: React

Leave a Reply

Be the First to Comment!

Notify of
Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.