Skip to content

[svelte] reactive_declaration_non_reactive_property #14644

Answered by Prinzhorn
razsa asked this question in Q&A
Discussion options

You must be logged in to vote

Did the migration tool create this code or you?

These two are not the same:

// Will always keep `darkMode` in sync with `darkModeStore`
$: darkMode = $darkModeStore;

// Defines a reactive state with _initial_ value of `$darkModeStore`
let darkMode = $state($darkModeStore);

You need to use $derived everywhere, because you are deriving state from a store.

https://svelte.dev/playground/7383f7af2c8e45868c34edf8fbbbcb4c?version=5.10.0

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Prinzhorn
Comment options

Answer selected by razsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants