-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
UI Reactivity Issue with Store Changes in Svelte 5 #16007
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
Comments
I think the problem here is each...if you directly print the store it updates properly but since the reference is the same the each is probably skipping the render |
I can confirm, when running the code below updates the UI items.update(items => {
const i = items.findIndex(item => item.id === id)
if (i > -1) {
items[i].value += 1
items[i] = { ...items[i] } // commenting this out will not update the UI
}
return items
}) The code below also updates the UI (but of course, nobody should do this) {#each items as item (`${item.id}-${item.value}`)}
<li>{item.value} <button onclick={() => onincrease(item.id)}>INC</button></li>
{/each} It would be nice if to know if this is the intended behavior and is a breaking change from svelte 4 -> svelte 5 for smoother migration |
I think the This seems to behave as expected if all logic is in the same component: Example |
No i think this is a bug...will try to fix later. |
Describe the bug
In Svelte 5, store updates no longer trigger UI reactivity in the same way they did in Svelte 4. While the store itself does update, the UI does not reflect these changes properly unless the $state version is used.
Expected Behavior
The UI should automatically update in response to store changes, as it did in Svelte 4.
Actual Behavior:
In Svelte 5, store updates do not trigger UI reactivity as expected, leading to inconsistent behavior.
Additional Information
If this change in behavior is intentional, clarification on how to properly ensure UI reactivity with stores in Svelte 5 would be helpful.
Reproduction
Steps to Reproduce
Open the following REPL for Svelte 4: Svelte 4 REPL
INC
button.Open the following REPL for Svelte 5: Svelte 5 REPL
INC
button.$state
version works fine.Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: