π React Mastery Series β Day 7

Frontend Developer | React & JavaScript | Building production-ready web apps Developer with 1.5+ years of experience, currently focused on React, Redux, and full-stack development. Sharing practical tutorials, concepts, and project learnings.
How React Rendering Works & Performance Basics (Beginner Friendly)
Many developers use React daily but donβt fully understand:
π When does React re-render?
π Why does UI update automatically?
π How to avoid unnecessary renders?
Letβs understand this clearly and simply.
π What is Rendering in React?
Rendering means:
π React runs your component function and updates the UI.
React renders when:
β
State changes
β
Props change
β
Parent component re-renders
π Simple Example
import { useState } from "react";
function App() {
const [count, setCount] = useState(0);
console.log("Rendered");
return (
<>
<p>{count}</p>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</>
);
}
π Every click triggers re-render.
β‘ Does React reload the whole page?
β No!
React uses Virtual DOM:
β’ Compares old UI with new UI
β’ Updates only changed parts
This makes React fast.
π« Common Cause of Unnecessary Renders
setCount(count); // causes render even if value same
Better:
setCount(prev => prev);
(React may skip if no change)
π― Performance Tip #1 β Keep state minimal
Donβt store values that can be derived.
Bad β
const [fullName, setFullName] = useState(first + last);
Good β
const fullName = first + last;
π Performance Tip #2 β Use React.memo (quick intro)
const Child = React.memo(({ name }) => {
console.log("Child rendered");
return <p>{name}</p>;
});
π Prevents re-render if props donβt change.
β Important Truth
React re-rendering is NORMAL and FAST.
Only optimize when you see performance issues.
β Key Takeaways
β React re-renders on state/props change
β Virtual DOM updates efficiently
β Keep state minimal
β Optimize only when needed
π Coming Next in Series
Day 8 β Lifting State Up & Component Communication
(Real project pattern!)
π¬ Did you know parent re-renders affect children?
Thank you for reading! π




