Navigate
Search topics, hooks, and fundamentals
Every hook interacts with the render cycle. Understand rendering first, and hooks will make perfect sense.
π‘ Every React hook depends on the render cycle. Understanding rendering is the foundation everything else builds on.
These are the patterns that trip up developers most often. Switch between Wrong and Fixed to compare the code side by side.
function Parent() {
// New object created every render β child always re-renders
const style = { color: "red", fontSize: 16 };
return <MemoizedChild style={style} />;
}function Parent() {
const [count, setCount] = useState(0);
return (
<div>
<button onClick={() => setCount(c => c + 1)}>+</button>
<p>Count: {count}</p>
{/* ExpensiveList re-renders even though items didn't change */}
<ExpensiveList items={items} />
</div>
);
}function SearchResults({ items, query }) {
// Filters 10,000 items on EVERY render, even if nothing changed
const filtered = items.filter(item =>
item.name.toLowerCase().includes(query.toLowerCase())
);
return filtered.map(item => <div key={item.id}>{item.name}</div>);
}