ncthbrt / react-use-elmish

A React hook for unified purely-functional state and effect management
MIT License
57 stars 4 forks source link

Cancelling effects on unmount #9

Open allforabit opened 4 years ago

allforabit commented 4 years ago

Hi there, really nice idea to port the elm(ish) architecture to react hooks. It seems like a very nice approach!

Perhaps there's a way of working around but the effects don't seem to cancel on unmount. For example if I copy and paste the tick tock example into a component and then navigate to cause a component unmount it causes an error (in react dev mode).

ncthbrt commented 3 years ago

Hi @allforabit. Cancellation of effects is an interesting one.

I'd be open to suggestions on how to achieve this in a way that still makes defining effects simple and is at least somewhat backwards compatible with the current way of doing things.