S
SolidJS7d ago
luis

createEffect not re-runing when value in accessors are changed

The createEffect in the print is not re-running when prop accessor is changed, is this some problem to reactivity? What i want is to run the effect everytime the param accessors are changed.
No description
14 Replies
zulu
zulu7d ago
how and what do you pass to the adjustments prop
luis
luisOP7d ago
Ok, somehow i don't know what i changed but worked out. But i have another question, is there a way to run this effect, by having dependencies? like in react, or i HAVE to use the accessors somehow?
zulu
zulu7d ago
what do you consider dependencies ? the accessor is a dependency
luis
luisOP7d ago
Yes but, this works because im using in console log, i mean, is there a way to do this without console logs?
zulu
zulu7d ago
can you give me an example of what you are trying to do
luis
luisOP7d ago
in react you pass a list of dependencies want to be calling a re-draw canvas function everytime prop.adjustments() changes. basically thats it
zulu
zulu7d ago
and your canvas is inside your component can you show a little bit more code
luis
luisOP7d ago
i want the effect to rerun without having to console log, by depending on adjustments
No description
zulu
zulu7d ago
i mean of the component this should work
luis
luisOP7d ago
it works, thats not the question im asking now, i want a way to do this WITHOUT console.log, got it?
zulu
zulu7d ago
ok I get you now you can do props.adjustments() or use the on() inside the effect
luis
luisOP7d ago
like in react you do useEffect(fn, [dependencies])
zulu
zulu7d ago
createEffect(on( ()=>props.adjustments() , draw))
createEffect(on( ()=>props.adjustments() , draw))
if you have more than one dependency
createEffect(
on( ()=>[props.adjustments(), props.more()] , draw)
)
createEffect(
on( ()=>[props.adjustments(), props.more()] , draw)
)
import on from 'solid-js'
luis
luisOP7d ago
Worked out, thanks! didn't know on

Did you find this page helpful?