Skip to content

fix: properly update store values #12562

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

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-mice-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: properly update store values
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/reactivity/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function store_get(store, store_name, stores) {
entry.store = store ?? null;

if (store == null) {
set(entry.source, undefined);
entry.source.v = undefined; // see synchronous callback comment below
entry.unsubscribe = noop;
} else {
var is_synchronous_callback = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
return () => {};
}
};
let store3 = undefined;

// store signal is updated during reading this, which normally errors, but shouldn't for stores
let name = $derived($store1);
let hello = $derived($store2);
let undefined_value = $derived($store3);
</script>

<h1>{hello} {name}</h1>
<h1>{hello} {name} {undefined_value}</h1>
Loading