-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
updating a value in an each loop doesn't work under specific circumstances #509
Comments
Yes, you cannot bind to a loop variable as that breaks the bind reference. Use the direct reference instead, as in your working example. |
You'll need to use the index for the each loop like this: {#each $form.priceRules ?? [] as _, i} |
In svelte 4 it worked though for some reason. Do you know why? My problem is that I get a type error because if I do an array access |
I created a demo with the exact same components and files but with Svelte 4 and this time it works as expected. Is it something that needs to be fixed or can't we do anything about it because of some Svelte 5 limitation? |
@ciscoheat I'm sorry to bother again but we're in the middle of a Svelte 5 upgrade and can't proceed because of this issue.
|
Creating a component that is used inside, or instead of, the each loop can be a way to make it work. |
I created an issue in the Svelte repo and they acknowledged that it's a Svelte bug |
Here is my repro:
https://www.sveltelab.dev/xo9hz1kbl8dq9l9
Description
Somehow when binding to
$form
it doesn't have the correct form value inside theonUpdate
fn.The text was updated successfully, but these errors were encountered: