Home›Community›What is the difference between useCallback and useMemo in R…
What is the difference between useCallback and useMemo in React?
Coding Now Expert •
Jun 13, 2026 •
264 views
Both are React hooks for performance optimisation — they prevent unnecessary recalculations:
**useMemo — memoises a VALUE:**
```jsx
const expensiveResult = useMemo(() => {
return heavyCalculation(data); // only re-runs when 'data' changes
}, [data]);
```
**useCallback — memoises a FUNCTION:**
```jsx
const handleClick = useCallback(() => {
doSomething(id);
}, [id]); // only re-creates when 'id' changes
```
**When to use:**
- `useMemo`: expensive calculations (filtering large arrays, complex math)
- `useCallback`: passing functions to child components that use `React.memo`
**Key difference:**
- `useMemo` returns the result of calling the function
- `useCallback` returns the function itself