React Code Optimization Discussion
Q: How would you optimize a piece of React code (e.g., a component re-rendering too often or a slow list)?
A: Key techniques interviewers expect: memoize expensive computations with useMemo and stabilize callback references with useCallback to avoid unnecessary child re-renders; wrap pure child components in React.memo; avoid creating new object/array/function literals inline in JSX props (each render creates a new reference, defeating memoization); virtualize long lists (react-window/react-virtualized) instead of rendering thousands of DOM nodes; split state so unrelated pieces of UI don't all re-render off a single shared state object; and use the React DevTools Profiler to actually measure before/after rather than optimizing blindly. Be ready to walk through a concrete before/after code diff during discussion.