-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
oncreate issues with Nested Components in a loop of an array with items added before the end of the array #700
Comments
Looks like using the same array & unshifting the item also has the same issue. https://svelte.technology/repl?version=1.24.0&gist=3d12f2bbd599b5d73443c0ded72c808c Also, there are issue with adding items in the middle of the array. https://svelte.technology/repl?version=1.24.0&gist=a1a246237f812a6dfb6d27bc33392c93 Note that pushing the next item works... https://svelte.technology/repl?version=1.24.0&gist=136c0713ac5f2220a5a5adac0e4b9fb2 |
This is expected behaviour — when you go from In theory there's a simple way to get this to work, which is to use the syntax for keyed each blocks: {{#each things as thing @id}}
<!-- thing.id uniquely identifies each thing -->
{{/each}} That way, you are telling the first component that it's now second, and the second component that it's now third. Two problems however:
|
use anchor comments to preserve order in keyed each blocks with components
It seems like there are some tracking issues with a loop, changed arrays (unshifted item), & nested component (manifested in oncreate).
https://svelte.technology/repl?version=1.24.0&gist=3d12f2bbd599b5d73443c0ded72c808c
The expected output is:
The text was updated successfully, but these errors were encountered: