question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: v-for index as key on <transition-group> children

See original GitHub issue

Version

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:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
yyx990803commented, Dec 17, 2018

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.

5reactions
oduvancommented, Feb 18, 2020

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found