Interesting post for people using add/remove event listeners in hooks

I work on a system with some complicated UI that requires a bunch of custom JavaScript hooks. One thing I don’t love is tracking event listeners on mount to make sure I remove them when the hook is destroyed.

I came across this post this morning about AbortController which presents a very elegant way to have my event listeners removed without manually tracking them.

11 Likes

That’s great! Thanks for the tip