Run side effects (subscriptions, fetches, timers) safely with useEffect and learn cleanup and dependency arrays.
Rendering should be pure: same props and state → same output. Side effects are everything else: fetching data, subscribing to events, timers, manually changing the DOM, logging.
React runs your component function to compute the UI. Side effects don’t belong in the render phase (they can run async and cause inconsistent UI). So React gives you useEffect: run side effects after render, in a separate phase.