What is useEffect
in React?
useEffect
is a React hook that allows you to perform side effects in functional components. Side effects refer to operations that interact with the outside world, such as:
- Data fetching: Making API calls to retrieve data.
- Subscriptions: Listening for events (e.g., from WebSockets).
- Direct DOM manipulations: Changing the document title or manipulating third-party libraries that interact with the DOM.
- Timers: Setting up intervals or timeouts.