Signal dont update the class
I have two components one the principal with the signal and te other is the button, the class shloud update depending on the state but is not working, the state change, but the ui dont change
6 Replies
You're destructuring props in the Button component. This breaks reactivity. Instead, you can use
splitProps
:
In general, you want to avoid destructing props. So instead of destructuring with
simply use
and then use props.foo
and props.bar
.thanks this works, there is a method of doing in whit destructuring ?
yes, but with 3rd party tools. Without it, destructuring just breaks reactivity (it's a JS behavior)
well in that case split props is the good way of doing
thanks
there is this you can try if youd like to retain reactivity when destructuring https://solid-primitives.netlify.app/package/destructure
Solid Primitives
A library of high-quality primitives that extend SolidJS reactivity
this one produces a function per property so might not be the native destructuring you are looking for but it's close