React useEffect brought down Cloudflare - DDoS self!
-
You can read about it here: Cloudflare DDoSed itself with React useEffect hook blunder or this YouTube video: Cloudflare in trouble...
-
My standard practice now is to put all functions into useCallback, and not putting functions into any dependency array (there's no need for that if everything all of the component's functions are in useCallback hooks, right?). I also tend to have a useEffect with an empty dependency array for component init, and maybe one or two for monitored states. Most of my states are actually maintained in a Zustand store, and that store exposes a get/set function pair for every state because I don't always want to know when a state changes within a given component, but I still want to be able to get or set that state.
I don't know if this is "best practice" or not, but it seems to work out well...