What is the difference between useMemo and useCallback in React?
useMemo caches the result of a calculation, while useCallback caches a function definition; both only recompute when their dependencies change.
Frontend 路 Intern to senior
React questions test whether you understand how components render and update, not just whether you can build a form. Interns are asked about props, state and hooks; mid-level and senior candidates are asked why a component re-renders, how to prevent wasted work and how rendering strategies affect performance and SEO.
5 of 12 questions match
Clear filtersuseMemo caches the result of a calculation, while useCallback caches a function definition; both only recompute when their dependencies change.
Updating state triggers a re-render, while changing a ref's .current value does not; use state for data shown on screen and refs for DOM access or values that must persist without causing renders.
CSR renders in the browser after JavaScript loads, SSR renders the HTML on the server for each request, and SSG renders the HTML once at build time; SSR and SSG give crawlers and users content faster, which helps SEO.
A component re-renders when its state changes, its parent re-renders, or a context it consumes changes; you prevent wasted renders by moving state down, using React.memo, and keeping props referentially stable.
Measure first with the Profiler and Lighthouse, then reduce unnecessary renders, split code with lazy loading, virtualise long lists, and optimise images and bundle size.