You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Svelte chokes when altering the content of a nested store using the $ syntax.
(i.e)
<script>import{writable}from"svelte/store";letstore=writable({inner: writable("string"),});
$: ({ inner }=$store);
$: inner.set("new string");// this works //$: $inner = "other new string"; // this doesn't
$: $inner&&($inner="other other new string");// this works!?</script><h1>Hello {$inner}!</h1>
Logs
Results in a Cannot read property 'set' of undefined error.
related #4516 $: $inner = "other new string"; is a "one time reactive statement", those run before reactive statements, $inner was still undefined when you attempted to change its value
another fix could be to define your nested store within the static top level block :
Describe the bug
Svelte chokes when altering the content of a nested store using the
$
syntax.(i.e)
Logs
Results in a
Cannot read property 'set' of undefined
error.To Reproduce
REPL repro
Expected behavior
I should be able to assign a value to a nested Svelte store using the
$
systax.Severity
Low severity. It's only a convenience, and probably a rarely used pattern to nest stores.
Additional context
I'm not familiar with Svelte internals but I suppose this may be vaguely related to #4079 and #3637 ??
The text was updated successfully, but these errors were encountered: