-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
SSR: writable store set in component does not update $store
variable
#3636
Comments
It looks like <script>
import { writable, get } from 'svelte/store'
const name = writable('Peter')
$: name.set('Joe')
$: console.debug($name)
$: console.debug(get(name))
</script>
<h1>Hello {$name}!</h1> |
This looks like a similar issue to #3582 but I'm not sure whether they're the same. |
They look similar but the behavior is different. #3582 is an undeclared variable while this issue is the store convenience variable ( |
This is finally fixed in 3.31.2 as part of a more sweeping change to how store autosubscriptions are handled in SSR code. See the generated code for https://svelte.dev/repl/e8ab45ee0a1e44ff8da3d09a427e201d?version=3.31.2 |
Here is the repro. https://svelte.dev/repl/e8ab45ee0a1e44ff8da3d09a427e201d?version=3.12.1
You have to look at the SSR output to see the issue, since the repl does not render SSR.
Notice that
$name
is defined beforename.set('Joe')
& is not updated afterwards. This causes the SSR to render the state from the previous request.The text was updated successfully, but these errors were encountered: