A mySignal.value
in an unused execution path will not trigger updates
#621
Labels
documentation
Improvements or additions to documentation
current:
1.3.0
Environment
@preact/signals-core
@preact/signals
@preact/signals-react
Describe the bug
Hi, this might not be a bug as it might be obvious to some, but for me, a Preact/Signals user of two weeks, this was a bit of a gotcha as I don't think it was mentioned in the docs and a colleague told me that accessing the
.value
is what causes the magic. Although in hindsight, it does make sense if I think about it. To my defense, though, I thought that it is done (the detecting of functions that access signals.value) via static code analysis, whereas it seems that it is done by actual runtime execution path. - again, it really makes sense.To Reproduce
Please provide a link to a StackBlitz/CodeSandbox/Codepen project or a GitHub repository that demonstrates the issue.
Steps to reproduce the behavior:
Expected behavior
What should have happened when following the steps above?
There are two things that could be made better
mySignal.value
needs to be reached and accessed ("accessing"mySignal.value
is not enough if it is not reached and executed, or in other words "accessed" - a term used in the documentation, but which kind of obscures the actual message).And maybe even write a recommendation to adopt this style to define signals upfront.
The text was updated successfully, but these errors were encountered: