No warning in console on rendered list without specifying key attribute
Vue version
3.3.2
Link to minimal reproduction
Steps to reproduce
Example ready as is.
What is expected?
I expect to have warning in console on list being rendered using v-for without binding the key attribute. Like it was in Vue 2 (component lists rendered with v-for should have explicit keys. See https://v2.vuejs.org/v2/guide/list.html#key for more info.) or like it is now in React.
What is actually happening?
No warning is being shown.
System Info
No response
Any additional comments?
No response
You don't actually need key
on v-for loops in Vue 3:
https://v3-migration.vuejs.org/breaking-changes/key-attribute.html
@LinusBorg That documentation doesn't mention anywhere that key
isn't needed on v-for - it only says so about v-if. Can the docs be updated as a source of truth? (e.g. google finds this SO post https://stackoverflow.com/a/70987261)
@LinusBorg That documentation doesn't mention anywhere that
key
isn't needed on v-for - it only says so about v-if. Can the docs be updated as a source of truth? (e.g. google finds this SO post https://stackoverflow.com/a/70987261)
Was about to say the same thing.
Yeah i got something mixed up with that migrationg guide link.
Yet in a sense it still applies: v-for does not always need a key. our docs have a separate section detailing when to use a key:
https://vuejs.org/guide/essentials/list.html#maintaining-state-with-key
Hence why we provide an eslint rule to recommend adding a key, but don't log out a runtime warning from Vue itself.