Mastering React Series: useEffect Hook
useEffect is a Hook in React that allows you to manage side effects in your functional components. A side effect is any state or behavior change that occurs outside of the render function . Some common examples of side effects include: Fetching data from an API Setting and updating a timer Listening to and responding to browser events Updating the document title With useEffect , you can run these side effects and keep your components clean and focused on rendering UI. Usage syntax : useEffect takes two arguments : The first argument to useEffect is a function that contains your effect code. This function is called every time your component is rendered, and its purpose is to manage your side effect. The second argument is an optional argument to useEffect is an array of dependencies . This array is used to tell React when to re-run your effect. There can be three scenarios : I. Passing a dependency array with some states: In this case, useEffect will r...