Hack to render
I have a signal
pValue that takes values on input blur
it's a prop for a component rendered in the return
<Graph P={pValue()}/>
This component is not re-render on pValue change, so I did a hack
It's ugly but it works.
Why is happening this and how I can solve it?
9 Replies
how are you reading
P
inside of the Graph?
Solid doesn't (generally) rerender so the issue could be where you're using the P
proplet P = props.P;
and then I use P in d3js do create some graphs
okay but where and how is the code written? For example, if you do something like this it won't work:
In order for it to be reactive, you need to read
props.P
in a reactive scope like the JSX or an effect
Unlike React, Solid doesn't rerender the whole component. So the P
inside Graph
will always be the initial value of props.P
when the component was mounted.so if for example I add console.log(props.P) it should re render? just as a vague example
no, you would have to wrap the console.log in a createEffect
Now it will log any time
props.P
changesnot working, this is my createEffect
what isn't working?
Also, createEffect doesn't have a dependency array. You can remove that
Also, you're access
P
but it's not in the effect
the P
here isn't in the effect. Add let P = props.P
inside the effectthat solved it, 1000 times thanks, now I know a little better how solid work.
Thanks again budy
No problem!