React setState reconciliation phases explained

What happens actually when you call setState() (Reconciliation phases) 1. Render phase: - React creates Virtual DOM - Compares it with previous one - Decides what needs to change - No real DOM updates here 2. Commit phase: - React applies the changes to real DOM. - Runs lifecycle methods and hooks like: useLayoutEffect 3. Commit phase (Final step): - Runs side effects: useEffects: - Cleanup of previous effects Understanding reconciliation helps you write better, performance-friendly components. #frontend #reactjs #javascript

To view or add a comment, sign in

Explore content categories