SolidJSS
SolidJS2y ago
17 replies
hannus

How can I make createEffect in SolidJS execute only when the dependency variable changes, and not wh

For example:
const [value, setValue] = createSignal<string>("")
createEffect(() => { localStorage.setItem("value", value()) })

I want to save the value to localStorage only after modifying the value, but do nothing when it is initially created with the value "".
I remember that in previous documentation, createEffect wouldn’t execute if the dependency variable was false or undefined. But it seems that this behavior has changed now.
Was this page helpful?