DEV Community

Discussion on: I made a mistake implementing a React Hook and got a denial of service from my backend

dance2die profile image
Sung M. Kim

Thanks for sharing the failing experience and the lesson learned, DrKnoxy 👋

Hooks are great and sometimes being explicit about reading life cycle method names (cDM, cDU, cWU, etc).

From what I've learned React used to tell us what it was doing but the trend is that we devs are now responsible to tell what React should do

e.g.) componentDidMount -> React tells us what we are doing and we had to figure out how to use that lifecycle
useEffect -> We tell React what we want to do, and when.

So we are given a dangerous weapon and be careful of how to use it as mentioned in your post 😀

itaditya profile image
Aditya Agarwal

I think both are same in this regard. React let's us hook arbitrary code between it's render cycle. Before we assigned a function to cDM etc. and now we do it by passing a callback to useEffect