React
Introduction to React Hooks - useEffect()

Replacing componentDidMount & componentDidUpdate()

PRO
Outline

Follow along as we see how to implement useEffect into our code. We have two primary objectives with this example:

✅ To generate a random number on page load

✅ To generate a a random number every time the UI updates

Using lifecycle hooks, you'd use ComponentDidMount to generate a new number for the page load. You'd also use ComponentDidUpdate to generate a new number every time the page updates. But the useEffect hook can handle both of these scenarios with one effect!

You can view this example on Stack Blitz

 

I finished! On to the next chapter