-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
No fine-grained reactivity #490
Comments
Here is a way that you may be able to work around this issue: <script lang="ts">
import { superForm } from 'sveltekit-superforms';
const superform = superForm({ foo: `I'm getting logged eventhough I don't change`, bar: 0 });
const { form } = superform;
const myInspectValue = $derived($form.bar)
$effect(() => {
console.log(myInspectValue);
});
</script>
<button onclick={() => ($form.bar += 1)}> Increment </button>
{$form.bar} |
That only masks the problem. It doesn't change the fact that |
It seems like that's how stores work, and as Superforms will keep them for the next major release (as they aren't deprecated, and a rewrite would be too much work), maybe the onChange event could be an alternative. |
@ciscoheat |
I also ran into this while trying to do reactive field updates - this is a known breaking change in svelte 5 per sveltejs/svelte#14306 |
Description
Currently I'm using superforms with Svelte 5 just fine. However, when I use $effect or some reactive code on a field input value, it will trigger on every other field updates. I guess because for Svelte 4 reactivity to work, the whole form store must be reassigned. Svelte 5 reactivity is fine grained so it doesn't trigger unnecessary reactions, so this is kind of unexpected when using Svelte 5. Honestly I don't think this is a bug because it's just the way Svelte 4 works. I also don't think this can be easily fixed without migrating the library from using stores to runes. However, @ciscoheat told me to open an issue so here I am.
If applicable, a MRE
https://www.sveltelab.dev/fxpfuy1f7nhvp8t
The text was updated successfully, but these errors were encountered: