We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
$effect
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
Consider the following code. It prints 1 to the console, followed by 10 – as expected.
1
10
let state = $state({ value: 1 }); $effect(() => { console.log(state.value); if (state.value == 1) { state = { value: 10 }; } });
Now wire up these actions to buttons A and B. Click either of them.
// Button A function set100() { state.value = 100; } // Button B function replaceWith1000() { state = { value: 1000 }; }
Clicking either button A or B should re-run the effect, hence printing either 100 or 1000 to the console.
100
1000
Clicking button A doesn’t re-run the effect. Only clicking button B does.
5.24.0
Still works in 5.23.2: https://svelte.dev/playground/9feb1af4faa04465ac1cc7da439fe69e?version=5.23.2
5.23.2
Broken in 5.24.0 and onwards: https://svelte.dev/playground/9feb1af4faa04465ac1cc7da439fe69e?version=5.24.0
System: OS: macOS 15.3.2 CPU: (10) arm64 Apple M1 Max Memory: 4.16 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 23.9.0 - /opt/homebrew/bin/node npm: 11.2.0 - /opt/homebrew/bin/npm Browsers: Brave Browser: 134.1.76.74 Chrome: 135.0.7049.115 Safari: 18.3.1 npmPackages: svelte: ^5.0.0 => 5.28.2
annoyance
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Reproduction
Consider the following code. It prints
1
to the console, followed by10
– as expected.Now wire up these actions to buttons A and B. Click either of them.
Expected behavior
Clicking either button A or B should re-run the effect, hence printing either
100
or1000
to the console.Actual behavior
Clicking button A doesn’t re-run the effect. Only clicking button B does.
Further info
1000
), and then clicking Button A (now correctly prints100
).5.24.0
, most likely due to this change: feat: allow state created in deriveds/effects to be written/read locally without self-invalidation #15553Reproduction
Still works in
5.23.2
:https://svelte.dev/playground/9feb1af4faa04465ac1cc7da439fe69e?version=5.23.2
Broken in
5.24.0
and onwards:https://svelte.dev/playground/9feb1af4faa04465ac1cc7da439fe69e?version=5.24.0
Logs
System Info
System: OS: macOS 15.3.2 CPU: (10) arm64 Apple M1 Max Memory: 4.16 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 23.9.0 - /opt/homebrew/bin/node npm: 11.2.0 - /opt/homebrew/bin/npm Browsers: Brave Browser: 134.1.76.74 Chrome: 135.0.7049.115 Safari: 18.3.1 npmPackages: svelte: ^5.0.0 => 5.28.2
Severity
annoyance
The text was updated successfully, but these errors were encountered: