How to use createEffect with store?
I want to make createEffect when specific property is changed in store.
I know how i can do it with createSignal. But how to do it with createStore?
6 Replies
createEffect(() => console.log(foo.value))
just referencing value on foo will cause the effect to register to the tracking scope.
Omg Alex!!! It's so easy than I thought...Solid is amazing....Thanks and much respect for the gods who made Solid...
But Alex. I get this warning 'computations created outside a
createRoot
or render
will never be disposed'
How to solve this? I have store in a seperate file, not inside any component. And I'm writing createEffect too in seperate file...because there are many side effects I want to run without any componentsJust wrap it in createRoot, ie
If you want to return more than 3 values, consider an object instead of a tuple.
Thanks Alex always you are amazing.... What's the purpose of createRoot actually under the hood?
It sets up a tracking scope for reactive computations, i.e. effects, memos etc, for the cases this is not automatically done by render or hydrate.
You can also use it to have a self-destruct switch for effects.
should log 4 times and then is garbage-collected.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View