InterviewBuddy
All interview questions

What actually happens when React state changes?

Beginner

Answer

React schedules a render. It calls components to calculate the next UI, then commits the necessary changes to the DOM. A render does not always mean a DOM mutation.

Explanation

Think of rendering as drawing a new blueprint and committing as changing the building. Keep rendering pure; effects synchronize with external systems after commits.

Example

setCount(c => c + 1); // Schedule the next state