All jobs / Frontend / web developer
Frontend / web developer interview question · 1–3 years
When is useMemo worth it?
The strongest answer
When a computation is measurably expensive and its inputs change rarely, or when a stable reference is needed for a dependency or a memoised child; memoising cheap values costs more than it saves
Why it works
Right. Measure, then memoise the expensive and the reference-sensitive.
What a good answer covers
- Memoise expensive computations.
- Stable references for deps and memo children.
- Not by default.
- Profile first.
Answers that fall short
- Close, but not the strongest: On every derived value
Blanket memoisation adds overhead and noise. - Weak: Never; React is fast
There are real cases. - Red flag: To make state updates faster
It does not touch state updates.
Who gets asked this
More Frontend / web developer questions
- Why wrap a handler in useCallback?
- The team argues whether a field is `userId` or `user_id`. What is OpenAPI for here?
- When does React.memo help, and when does it not?
- The register API can fail because the email is taken or because the password is too short. What should the UI…
- The app feels sluggish when typing in one field. How do you find the cause?
- Where should state live, as a rule?
- Why do teams use a server-state library instead of useEffect plus useState for data?
- Choosing between client rendering, server rendering, static generation and streaming for a new product — how…