Skip to content

Bind value without reactivity #15186

Answered by brunnerh
karchung0930 asked this question in Q&A
Discussion options

You must be logged in to vote

$state is necessary for any reactivity, be it updating the UI, running an $effect or computing a $derived.

The $state fires change notifications which are required by $derived to know when the value needs to be recomputed; this is why your example will not work without $state.

If you are not using a value in any reactive context, e.g. only in some event callback, you can use a non-reactive variable for the binding. I probably would still not recommend doing this; code tends to change and chances are, you will need the reactivity at some point anyway; not having it may lead to buggy behavior/confusion if overlooked.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karchung0930
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