We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug When a prop (whose value is a store) changes, Svelte does not unsubscribe from the old store and subscribe to the new store.
This seems related to #2014 and #2435, which were previously fixed.
Logs See below.
To Reproduce With local variables, it works as expected: https://svelte.dev/repl/f8dca40374cd499b9b2df84a900d908b?version=3.12.1
s1 subscribe (swap) s1 unsubscribe s2 subscribe (swap) s2 unsubscribe s1 subscribe
With a component prop, it does not: https://svelte.dev/repl/fa8f0e0b78f743e5b1410c87885cf277?version=3.12.1.
s1 subscribe s1 subscribe (swap) s1 unsubscribe s2 subscribe
If <h1>outer $s = {$s}</h1> is commented out, no subscribe/unsubscribe occurs when the button is clicked.
<h1>outer $s = {$s}</h1>
Extra unsubscribe statements appear in the console when editing the code when the old component is unmounted.
Expected behavior The component should unsubscribe from the old store and subscribe to the new store.
Information about your Svelte project:
Severity It's not a big issue, but the current behavior seems surprising or counter-intuitive.
Additional context None
The text was updated successfully, but these errors were encountered:
Simpler repro:
Main.svelte
<script> import Foo from './Foo.svelte'; import { writable } from 'svelte/store'; let prop = writable(1); setTimeout(() => prop = writable(2), 1000); </script> <Foo {prop}/>
Foo.svelte
<script> export let prop; </script> {$prop}
After one second, this should switch from displaying 1 to 2, but does not. The $set handler
$set
$$self.$set = $$props => { if ('prop' in $$props) $$invalidate('prop', prop = $$props.prop); };
needs to also resubscribe to the store, like any assignment to prop would.
prop
Sorry, something went wrong.
Duplicate of #3662.
No branches or pull requests
Describe the bug
When a prop (whose value is a store) changes, Svelte does not unsubscribe from the old store and subscribe to the new store.
This seems related to #2014 and #2435, which were previously fixed.
Logs
See below.
To Reproduce
With local variables, it works as expected: https://svelte.dev/repl/f8dca40374cd499b9b2df84a900d908b?version=3.12.1
With a component prop, it does not: https://svelte.dev/repl/fa8f0e0b78f743e5b1410c87885cf277?version=3.12.1.
If
<h1>outer $s = {$s}</h1>
is commented out, no subscribe/unsubscribe occurs when the button is clicked.Extra unsubscribe statements appear in the console when editing the code when the old component is unmounted.
Expected behavior
The component should unsubscribe from the old store and subscribe to the new store.
Information about your Svelte project:
Severity
It's not a big issue, but the current behavior seems surprising or counter-intuitive.
Additional context
None
The text was updated successfully, but these errors were encountered: