I keep seeing this pattern in some solid code where dom refs are kept in signals.
Is there any advantage to doing it like this?
4 Replies
a possible usecase is a reference to an object that is a child of a
<Show/>
I see
that means I can reference it in an effect that reruns, when the button node changes. Is that correct?
exactly
some people prefer to use it in general, because of this and some other tiny edge cases
p.ex
refToChild would be undefined because it is not defined, and because it's not a reactive value it will not properly update
an extra signal, but in turn a bit less mental overhead
That makes sense, thanks