Skip to content

Svelte 5: Use index as key breaks each block #9868

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

Closed
Thiagolino8 opened this issue Dec 8, 2023 · 2 comments · Fixed by #9889
Closed

Svelte 5: Use index as key breaks each block #9868

Thiagolino8 opened this issue Dec 8, 2023 · 2 comments · Fixed by #9889
Assignees

Comments

@Thiagolino8
Copy link

Thiagolino8 commented Dec 8, 2023

Describe the bug

Simply using index does not change anything in the code, but if you use index in the key in some other way it adds a function but does not provide the index for that function
image

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAChWMQQqDMBAAv7Jse2hBEHoMpdB3NILBrHUhicFEoSz795rjDMwIzhyooPkIJhcJDb5zxg7rLzcoB4VKJ5d136Zm5EJuWkACpW9dDDwUXAGuFDtguI1XYR3vapOtT89H_7JJ-pboeYmr55nJo6nbTjroH6WtwoOAAAAA

Logs

No response

System Info

App.svelte (Svelte v5.0.0-next.22)

Severity

blocking an upgrade

@Conduitry
Copy link
Member

There are a couple things going on here. One is that your code isn't using the index as the key, it's using the literal string i. Your component doesn't work in Svelte 4 either. If you use (i) instead, it works in both 4 and 5

I do think the error message in Svelte 5 is wrong, though. It should say 'i', not 'undefined'.

@Thiagolino8
Copy link
Author

There are a couple things going on here. One is that your code isn't using the index as the key, it's using the literal string i. Your component doesn't work in Svelte 4 either. If you use (i) instead, it works in both 4 and 5

I do think the error message in Svelte 5 is wrong, though. It should say 'i', not 'undefined'.

Yes, the code was incorrect but the problem is real, I edited the issue to include the correct screenshot and repl
I had this problem in a real app and when creating a simplified repl I ended up writing it wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants