'Is the :key attribute mandatory in v-for loops?

i don't have a real problem, just i read somewhere once that a :key attribute in vue 3 is not mandatory in a v-for loop. Is this correct and if so, when do I need a key in v-for loops and when not? Or do I not need it at all ? What is it needed for if it is necessary?

Thanks a lot.



Solution 1:[1]

It's better for you to use it in all v-for loops.

The key special attribute is used as a hint for Vue's virtual DOM algorithm to keep track of a node's identity. That way, Vue knows when it can reuse and patch existing nodes and when it needs to reorder or recreate them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fdisotto