What does useCallback do in React?
useCallback takes a function and a dependency array and returns the same function reference across renders unless a dependency changes. Without it, a new function is created on every render, which can cause unnecessary re-renders.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in useCallback in React Explained: Avoiding Unnecessary Re-renders
When you pass a function as a prop to a child wrapped in React.memo. The stable reference prevents the child from re-rendering just because the parent created a new function on every render.
No. For functions used only inside the same component, the new reference is fine and useCallback adds overhead for no benefit. Use it only when passing to a memoized child or for handlers used in effects.
useMemo memoizes a value; useCallback memoizes a function reference. They are related but distinct; useCallback is essentially useMemo for a function. Use useMemo for computed values and useCallback for stable function references.
Still have questions?
Browse all our FAQs or reach out to our support team
