In React, when does the function you pass to
useEffect actually run, relative to the component's render?- aSynchronously during the render, before JSX is returned
- bAfter React commits the render to the screen✓
- cOnly when a parent component re-renders
- dBefore the render function runs
Explanation:
useEffect schedules its callback to run after the browser has painted the committed render — it is for work that reacts to a finished render (subscriptions, fetching, syncing with something outside React), not for computing what to render. Option (a) describes render-time logic, not an effect. Option (c) is wrong because a component's own render also schedules its own effects. Option (d) reverses the order entirely.