React Render vs Repaint Explained

React Render ≠ Repaint Many people think “render” means repainting the screen. In React, render means re-running the component function. What actually happens: 1. setState → schedules a re-render 2. React re-runs the component function 3. JSX is recalculated (Virtual DOM) 4. React diffs the result 5. Only then does the browser paint what changed 6. A render can happen without any repaint at all. Understanding this makes React performance and behavior much clearer. #React #JavaScript #WebDev #Frontend #LearningInPublic

Exactly. love it! This is the answer for "Why React?" I just want to add a small thing here, JSX doesn't get recalculated as per, React Element gets re-generated is the correct way to put it, as react runs these js objects generated by babel or any JSX parser via JSX runtimes (_jsx or _jsxs) which generate a React Element tree. React diff this React Element tree with the fibre tree 😀

To view or add a comment, sign in

Explore content categories