DEV Community

Discussion on: React 18 - Avoiding Use Effect Getting Called Twice

Collapse
 
jherr profile image
Jack Herrington

useEffectOnce exit is not going to fire as far as I can see. This hook works to defeat the hook being called twice, but the cleanup functions will never get called as far as I can see.

I honestly don't know how to fix this. I've been trying everything I can think of.

Collapse
 
eviltester profile image
Alan Richardson

Thanks for pointing this out Jack. Niall updated the code, hopefully it is better.