In React, a side effect is any operation that affects something outside the component's render scope—such as fetching data, setting up subscriptions, interacting with the DOM, or managing timers. React handles side effects using the useEffect() hook in functional components.
Used to load data from an API or backend service after the component renders.
Adding custom event handlers to window, document, or other DOM elements.
Setting up setTimeout or setInterval for delayed or repeated actions.
Changing the DOM directly outside React’s declarative system.
Connecting to WebSockets, Firebase, or any real-time data stream.