Custom Hooks for Reacts
Custom hooks are functions whose names start with use that call other hooks to package reusable stateful logic. Performance hooks such as useMemo, useCallback and memo-related patterns avoid repeated expensive work, but they should be added after measuring, because they also add complexity.
Stage: Hooks · Part of the React roadmap · Last reviewed 19 November 2026
What to learn in Custom Hooks
- Extract repeated stateful logic into a custom hook like useLocalStorage
- Return values and setters from a hook with a clear API
- Follow the rules of hooks about call order and placement
- Cache an expensive computation with useMemo
- Stabilise a function reference with useCallback for a memoised child
- Decide when memoisation helps and when it is wasted effort
Custom Hooks interview questions
What problem do custom hooks solve?
They let components share stateful logic, such as fetching, debouncing or subscribing, without duplicating code or using wrapper components. Each call to a custom hook gets its own independent state, so sharing logic does not share data.
Does useMemo guarantee a value is never recomputed?
No. It is a performance hint. React may discard cached values, for example to free memory, so the code must remain correct without it. Use it for measured costly calculations or to keep referential equality for dependencies.
Where Custom Hooks fits in the React roadmap
Custom Hooks belongs to the Hooks stage (intermediate level), which takes about 25 hours. Side effects and logic reuse.
Other units in this stage
Back to the full React roadmap