Vue: Key warning shouldn't be shown for transition keys

Created on 16 Jul 2017  路  2Comments  路  Source: vuejs/vue

Version

2.4.1

Reproduction link

https://jsfiddle.net/f3Lo2k0p/

Steps to reproduce

  1. Add :key binding in a transition

What is expected?

To not get a warning

What is actually happening?

Vue issues a warning:
"Avoid using non-primitive value as key, use string/number value instead."

However the key here is bound to a boolean property.

Most helpful comment

FYI, you can turn the boolean into a number by prepending +:

<div :key="+isEditing">

I guess adding it to the warning is enough but we could also make isPrimitive check if the vaule is a boolean

All 2 comments

A boolean is not a string or a number, so technically, you are not doing what the warning asks you to do. ;)

Still, we should look into it and see that boo leans are fine too.

FYI, you can turn the boolean into a number by prepending +:

<div :key="+isEditing">

I guess adding it to the warning is enough but we could also make isPrimitive check if the vaule is a boolean

Was this page helpful?
0 / 5 - 0 ratings