Sometimes you will need to properly clean up your effects to prevent memory leaks. Like if you use timeouts or intervals.
Implement cleanup logic using the onCleanup
callback. In your effect you can call onCleanup
, pass it a callback, and define actions like clearing intervals or unsubscribing from observables when effects are no longer needed.