What is useEffect?
In React useEffect is a hook for encapsulating code that has side-effects. useEffect is triggered after the render method is called.
Why we need useEffect?
We mainly use useEffect for the following usage:
- Fetching data
- Reading from local storage
- Registering and deregistering event listeners