Explain React useEffect lifecycle, dependency arrays, and race-condition cleanup
useEffect synchronizes React UI state with external systems (APIs, subscriptions, timers) after paint, re-running whenever dependencies change and invoking the returned cleanup function beforehand to cancel stale requests or listeners.