The key is an attribute that you must pass to all components created dynamically from an array. It’s a unique and constant id that React uses to identify each component in the DOM and to know whether it’s a different component or the same one. Using keys ensures that the child component is preserved and not recreated and prevents weird things from happening.
Use an existing unique value of the object.
Using array index is a bad practice.
You can create your own unique id. Be sure that the method is fast and attach it to your object.
When the number of children is large or contains expensive components, use keys to improve performance.
You must provide the key attribute for all children of ReactCSSTransitionGroup.