Not understanding signals
I have this component:
See parent opened being reactive just fine. 😄
Note for opened: () => local.opened!
Whatever I try. I just don't get any feedback.
What am I missing? The docs are a little too basic. I understand signals when all the code is centred within 1 component. Now a nested setup. I am lost.
Thanks! And please ELI5 it for me 😂
8 Replies
what is useProps doing
I thought I had used splitProps on this, but may have missed it. 😩
It's the spreading of the props that's probably breaking it
try using
mergeProps
with splitProps
instead to do that returnI finally have feedback 🥳
Now I have to figure out how to get use-props to work.
What do you mean using mergeProps with splitProps? 🤔
If I pull useProps into the component. I get reactivity. If I have
return mergeProps(defaultProps, contextProps, filterProps(props)) as any;I get no reactivity. 🙁
It's probably the
filterProps
that's breaking it
What does it do?
So to me that looks fine. But why doesn't solid like it? Btw, I removed filterProps and it works. That is the culprit.
reading the prop outside of a reactive context just gives the initial value of the prop. You're basically destructuring through that helper.
It's like if you have an object and you destructure it like this:
Solid transforms it's props into object getters
Finally got this to work. Just now remembered to update the thread: 😩
use-props.ts
I went with props
instead of filter(props)
as then I would lose the reactivity and I just couldn't get a working solution. No matter what I tried. 🤷♂️