Bind value without reactivity #15186
-
Is it valid and right to bind the value of an input to a variable without reactivity such as with
My question:
Unless here we make the data to be |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The 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. |
Beta Was this translation helpful? Give feedback.
$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.