useCallback in React

From the React Hooks cheat sheet · Performance · verified Jul 2026

useCallback

Memoize functions

javascript
// Memoize function to prevent child re-renders
const handleClick = useCallback(() => {
  doSomething(id)
}, [id])                                // Recreate when id changes

// Without dependencies (never changes)
const handleSubmit = useCallback(() => {
  dispatch({ type: 'submit' })
}, [])                                  // dispatch is stable
💡 Prevents unnecessary child re-renders
⚡ React 19's compiler auto-memoizes - often unnecessary now
✅ Use when passing callbacks to memoized components
⚠️ Don't use for every function

More React tasks

Back to the full React Hooks cheat sheet