What is React? JSX Introduction and Your First Component
What problem React actually solves, how JSX syntax works, and how to build your first component.
The default behavior is: whenever a parent component re-renders, all of its children re-render too — whether their props changed or not. In small apps this isn't an issue, but for heavy components (large lists, charts) it can become a real performance problem.
const ProductCard = React.memo(function ProductCard({ name, price }) {
console.log('Rendering:', name);
return (
<div className="card">
<h3>{name}</h3>
<p>₹{price}</p>
</div>
);
});
React.memo wraps a component and does a shallow comparison of its props — if every prop is the same as the last render, React skips re-rendering that component entirely and reuses the previous result.
// This function is a NEW object every time the parent re-renders:
<ProductCard onClick={() => addToCart(id)} />
// React.memo will treat this as a "different prop" and the memo becomes useless!
To fix this, the function in the parent needs to be stabilized with useCallback — React.memo and useCallback are often used together.
React.memo skips a component's re-render when its props are unchanged.useCallback/useMemo.What problem React actually solves, how JSX syntax works, and how to build your first component.
Set up a modern React project in seconds with Vite, and understand the resulting folder structure.
Build functional components and pass data from parent to child components using props.