-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate {{each}}
without a key specified.
#11337
Comments
A good number of each's in the various apps I've worked on do not have any stable unique prop to key to. It's quite a pain to have to decorate each item with a key. Can this be helped in some other way? What about auto-generating In testing canary with one of our apps, we noticed some incorrect dom-reuse when the array changed. (more info on that as we discover the cause, we'll create a ticket) |
There will be "@index" and "@Guid" that you can use (@index is what we are using now by default). |
This is generally because of the default usage of the item's array index as key. |
What about defaulting to "@Guid"? |
It has been done. |
Whoops, sorry I thought you meant adding |
Maybe instead of deprecating, we just spit out a warning whenever there is an each without a key. |
@knownasilya - How is that much different? People should be supplying a key, deprecation vs warning doesn't seem to make much difference there... |
Because deprecation means eventual removal, but as in @jayphelps' case there is that case where there is no stable id. But I guess that's a small use case. Really if you have that, then just use guid, otherwise use a key? I guess I'm convinced 😸 |
In either case
Completely agreed. I'll review with the rest of the team before deprecation. If we intend to allow keyless usage long term (like when we can have native ES6 Map's and don't need to mutate the object) we should not deprecate. |
I have implemented as warning for now, closing... |
i feel like the syntax is looking a bit unfriendly... complicating what should be a simple looping construct. my opinion only. i also don't know what "@index" is or where it's coming from or what the difference is between it and "@Guid"... |
simple=inefficient. Not sure how key='option' is unfriendly.. @Guid is a generated guid, probably based on the item |
if "@Guid" is the new default, why are we required to specify it? |
@christophermlne it's not the default. Previously it was @index, but that isn't performant so now you "must" specify a key or you see a warning. |
We must specify one key or another, so if the recommended "fast" option is @Guid. why not make it a default? |
Great point, I submitted a PR for exactly that :) |
The each helper documentation implies that this key is purely to help the renderer. I shouldn't have to care about that. Convention over configuration etc..... |
@rwjblue fixing code even before someone realize there's a problem with it since: 'xx :) |
FYI, this warning was removed in favor of a default key of |
@gerry3 - Correct, I missed the commit when I released 1.13.1, I will be shipping a 1.13.2 within a day or two. |
Thanks @rwjblue! Just wanted to make sure anyone who came across this thread knew the plan. |
The default key of
index
is confusing. We should deprecate usage of keyless{{each}}
.The text was updated successfully, but these errors were encountered: