-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Svelte 5: Reactivity bug with spread operator #10065
Comments
Looks like the compiler does not generate a Spreading this on the other hand would work: const props = $derived({
"aria-pressed": pressed,
onclick() { pressed = !pressed },
}); |
Is this fine-grained or does the entire object get revalidated? |
This would recreate the object on change. What is the use case for doing this, though? |
I was migrating some melt-ui code to runes. Props are spread into elements react-aria style. <script>
const { elements: { root } } = createLabel();
</script>
<!-- In the migrated code, `root` is an object rather than a store -->
<label use:root {...$root} /> |
Could you please take a look at this issue (#10007) revolving around the same problem? I made the issue about a week ago but didn't get any answers and I think it's kind of important as it can cause serious performance issues and unexpected behaviors. |
I think this is expected, though. const x = $derived(x_expression);
const y = $derived(y_expression);
return {
get x() { return x },
get y() { return y }
} |
Let's not discuss separate issues here. As for the lack of responses: Most maintainers are probably still on holiday, and I am not a maintainer, I just meddle 😅. Also, Svelte 5 is not even officially released yet and there are quite a few issues that still need to be ironed out - there is no need to be impatient. |
The objects could contain getters with reactive values, so we play it safe and assume they're always reactive fixes #10065
Describe the bug
Spreading an object with reactive props doesn't work as expected.
Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: