useCallback

React Native 6 min min read Updated: Aug 03, 2026 Intermediate
useCallback
Intermediate Topic 8 of 18

useCallback

The useCallback hook memoizes a function reference, ensuring the same function instance is reused across renders unless its dependencies change, which helps prevent unnecessary re-renders of child components.

Basic Syntax

javascript const handlePress = useCallback(() => { console.log('Button pressed'); }, []);

Why Function References Matter

Without useCallback, a new function instance is created on every render, causing memoized child components using React.memo to re-render unnecessarily since their props appear to have changed.

javascript // Without useCallback, this creates a new function every render const handlePress = () => navigation.navigate('Details', { id: item.id });

Using useCallback with Memoized Children

javascript const ListItem = React.memo(({ item, onPress }) => ( {item.name} )); function ParentComponent() { const handlePress = useCallback((id) => navigation.navigate('Details', { id }), [navigation]); return handlePress(item.id)} />; }

useCallback with useEffect Dependencies

useCallback is also useful for stabilizing function references used inside useEffect dependency arrays, preventing effects from running more often than necessary.

When to Use useCallback

useCallback is most valuable when passing callback functions to memoized child components or including them in other hooks’ dependency arrays, not for every single function in your component.

Common Mistakes with useCallback

  • Using useCallback for functions never passed as props or used in dependency arrays
  • Forgetting to include all values referenced inside the callback in the dependency array

Conclusion

The useCallback hook helps maintain stable function references, which is particularly valuable when combined with React.memo to prevent unnecessary re-renders of child components in React Native applications.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators