Error: v-for index as key on <transition-group> children
See original GitHub issueVersion
2.5.21
Reproduction link
https://jsfiddle.net/edugodsinmetr/p1fdze9y/
Steps to reproduce
Using v-for index as key on <transition-group>
What is expected?
No error
What is actually happening?
Error “Do not use v-for index as key on <transition-group> children, this is the same as not using keys.”
I think I had no errors with this implementation before. My workaround to this issue was to add a number to the index value :key="i+1"
but I’m not sure if I should do it.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
v-for index as key on <transition-group> children with object ...
Hey guys, I recently updated vue-cli and got this new error: Do not use v-for index as key on children, this is the...
Read more >Vue(tify) Transition- children must be keyed - yet there are not ...
Inserted that into my component and saw it working. Thus no issue with setup or vue. Then later figured out i was referenced...
Read more >"transition-group children must be keyed" - which they are, but ...
This code has keyed children (:key="composition.id), but I still get a warning message in the browser console: <transition-group ...
Read more >Vue.js bug using index as key for transition-group ... - CodePen
The error is that the last item is animated each event instead of the intended target. 3. This one FAILS ALSO, the transition...
Read more >Vue: <transition-group> children must be keyed <div>
So I'm making a custom vue info slider and I'm getting the following error in the console: [Vue warn]: children must be keyed:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When using index as key on a
<transition-group>
, your list will never have any moving animation when the list is reordered. That defeats the purpose of using the<transition-group>
… even if your code happens to work, you still should provide a unique key because it will break when your list is reordered.@yyx990803 the actual confusion here is that with having a key attr I see a warning
Do not use v-for index as key on <transition-group> children, this is the same as not using keys.
And without key attribute it doesn’t work.
Maybe we should remove a warning then?
Thank you