how to`createStore` and using `createEffect` to persist without warning
I want to create a function to persist the store to the localstorage, everything works, but it warns that
computations created outside a
createRoot or
render will never be disposed
. I have tried to move createEffect
outside onMounted
, but it even warn twice. Additionally, moving onMounted
inside provider
makes persist break. No help using ChatGPTš„². Does anyone know how to solve it?
here is my code
1 Reply
well, I finally struggly solve it my self. According to https://github.com/solidjs-community/solid-primitives/blob/main/packages/context/src/index.ts, wrap
onMount
with a function and call it in createComponent
, and all works without warn