Skip to main content
React Interview Questions Concept Queue P0 Medium

Search results are always one render behind

A list component keeps filteredRows in state and updates it in an effect whenever props.rows or query changes. The filter is fast and synchronous. Explain why a render can show the previous results and what you would change.

Official Reference

Model Answer & Explanation

The component first renders using the old filteredRows, then the effect runs after commit and schedules another render. The filtered list is a pure function of rows and query, so compute it in render instead of storing a second source of truth. Consider memoizing only if the calculation is measurably expensive.

What a Strong Answer Covers

  • Identify the extra render caused by storing derived state.
  • Keep rows and query as inputs and calculate the list during render.
Follow-up Interview Question · Would a user-editable draft initialized from props be the same situation?

Module Context & References

React · Applied concepts Explain the state, identity and effect bugs behind real UI behavior.
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.