It is a lightweight in-memory representation of the actual DOM to track changes in the UI and efficiently update the real DOM when necessary.
useState: to add and manage state to functional components
useReducer: to add and manage complex state
useEffect: to execute side effects during rendering and hooking into lifecycle hooks
useMemo: to memoise the output of a function
useCallback: to memoise a function declaration when a function is passed to children components that are memoised.
useContext: to access context object
useLayoutEffect: synchronously useEffect
useRef: to access and manipulate DOM and store values that do not cause rerender on updates.
use
useDebugValue
useId
useDeferredValue
useTransition
useSyncExternalStore
useInsertionEffect
useImperativeHandle
How would you add a piece of local state to a functional component that toggles a modal open and closed? Which hook would you use and why?
If you need to run some code once after a component mounts to fetch initial data, which hook would you choose and what would the dependency array look like?
What happens if you call a hook conditionally inside an if statement? Explain the rule that prevents that.
You have a component that fetches user data in useEffect, but it keeps refetching on every render. Walk me through how you'd debug the dependency array.
When would you prefer useReducer over useState for managing form state in a medium‑sized feature? Discuss trade‑offs.
Explain how you would create a custom hook to share a WebSocket connection across multiple components, and how you'd handle cleanup.
A list component suffers from unnecessary re‑renders because a callback prop changes on each render. How would you use hooks to mitigate this and what are the performance implications?
You need to expose an imperative method (e.g., focus) from a child functional component to its parent. Which hook would you use and how would you implement it?
Describe how you would refactor a large class‑based component that uses lifecycle methods into a functional component using hooks, ensuring behavior stays identical.
Your organization is migrating a legacy codebase of 200+ class components to hooks. What strategy would you propose to do this incrementally while minimizing risk?
How would you design a shared state solution across many unrelated parts of the app using hooks, and what are the considerations for scalability and testing?
When introducing a new custom hook library across multiple teams, what guidelines and patterns would you establish to keep the API stable and avoid hook misuse?