DEV Community

Discussion on: 🍦 Cancel Properly HTTP Requests in React Hooks and avoid Memory Leaks 🚨

Collapse
 
nans profile image
Nans Dumortier • Edited

Heya !
Thanks for this well detailed article!!
I was facing the exact same issue, so I created this hook :
npmjs.com/package/use-state-if-mou...
It basically works like React's useState, but it only updates the state if the component is mounted !
I thought it's an easy and elegant solution for that issue, what do you think ?

Collapse
 
viclafouch profile image
Victor de la Fouchardière

Yeah that's an idea ! I love that !! :)