re: I used effects, said goodbye to my lifecycles, and feel 🙂 VIEW POST

FULL DISCUSSION
 

Hey Thomas, great article!

You've got one thing wrong though. To remove an event listener you have to pass the same callback function you've passed when created it.
Using an anonymous function will not work here. return () => document.removeEventListener("keydown", () => {}); will do nothing.

Check those:
w3schools.com/jsref/met_element_re...
developer.mozilla.org/en-US/docs/W...

 

Hey Radu! Thanks for the feedback. To be honest, I was quite unaware of this, but thinking about it, it actually makes sense :)

I've updated the code! Thanks again :)

code of conduct - report abuse