Question presented to candidate: "What are Hooks, why were they introduced, and which ones do you actually reach for?"
What a strong answer should cover:
- Hooks are functions that let a function component use React features — state, effects, context, refs — that previously required a class.
- Introduced in React 16.8 (2019). The motivation: sharing stateful logic was only possible via HOCs and render props, both of which added wrapper components.
- The Rules of Hooks: call them unconditionally, at the top level, and only from a component or another hook.
- The common ones, grouped:
useState/useReducer(state),useEffect/useLayoutEffect(effects),useContext(context),useRef(persistent values and DOM),useMemo/useCallback(memoisation). - Modern additions worth naming:
useTransition,useDeferredValue,useSyncExternalStore,useId, and the React 19 set —useActionState,useOptimistic,useEffectEvent. - Custom hooks are the payoff: any
use-prefixed function composing other hooks. - They did not replace classes for everything — Error Boundaries still need one.
Clarifying questions expected:
- "Do you want the full list, or the ones I use day to day?"
Code / implementation expected: Optional. A component using two or three hooks together is enough.