Fetching Data (and avoiding infinite loops)
Learn how to run code a single time after a component mounts, with useEffect and the empty dependency array [].
In the days of classes and lifecycles, this would've been done in componentDidMount -- right after the component first appears on screen. With hooks, useEffect serves the same purpose.
Here you'll learn how to do that, and how to avoid an infinite render loop in the process.
Code: before and after
In the days of classes and lifecycles, this would've been done in componentDidMount -- right after the component first appears on screen. With hooks, useEffect serves the same purpose.
Here you'll learn how to do that, and how to avoid an infinite render loop in the process.
Code: before and after