What is the difference between useMemo and useCallback?
useMemo memoizes a computed value so it is not recomputed unnecessarily. useCallback memoizes a function so it keeps the same reference. Both prevent unnecessary work, but should be used only when there is a measured reason, not by default.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Top React Hooks Interview Questions With Answers
Hooks let functional components use state and effects that previously required class components. They were introduced to solve class problems: lifecycle methods splitting related logic, a confusing this keyword, and hard-to-share stateful logic.
useState is for simple, independent state. useReducer is for complex state with transitions, modeling state as a reducer that takes the current state and an action. Choose based on the complexity and clarity of your state logic.
useEffect runs side effects like data fetching, subscriptions, and DOM updates after render. The dependency array controls when it runs: on every render, only on mount, or when specific values change.
Still have questions?
Browse all our FAQs or reach out to our support team
