x-intersect messes with unshift() & item order #1941
-
I'm not sure how much more generic I can make this, but in my use case, I have an array of photo urls. I use Alpine to The problem is that when I add a new url to the list with You can see an example here: https://codepen.io/quasipickle/pen/GRmzyWV So it would appear |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
None of them, the problem is with x-for. your x-for is keyed by numeric index so when it repaints it updates existing elements. You need to use a unique reference that is bound to the entry, try using the url for example. In general, keying by index always leads to bugs if your list is meant to change. (also if you want to key by index |
Beta Was this translation helpful? Give feedback.
None of them, the problem is with x-for. your x-for is keyed by numeric index so when it repaints it updates existing elements. You need to use a unique reference that is bound to the entry, try using the url for example. In general, keying by index always leads to bugs if your list is meant to change. (also if you want to key by index
:key="index"
is redundant since it's the default behaviour