SolidJSS
SolidJSโ€ข2y agoโ€ข
5 replies
Ditto

What is the most idiomatic way of disabling an effect after a condition is met?

Is it possible to disable an effect after some condition is met or should I just use an early return?

const [value, setValue] = useSignal<number | undefined>();

createEffect(() => {
  if (value() !== undefined) {
    // do something with value() then disable this effect
  }
})
Was this page helpful?