Skip to main content
React Interview Questions Concept Queue P0 Medium

A draft leaks into a different conversation

A ChatPane holds its input draft in local state. Switching from Alice to Bob changes the recipient prop, but Alice’s unsent draft remains in the input. Explain why. How would you implement a fresh draft on switch? What if the product instead wants to preserve a separate draft for each recipient?

Official Reference

Model Answer & Explanation

The same component type remains at the same tree position with the same identity, so changing a prop does not reset its local state. Use key={recipientId} on ChatPane to intentionally remount and reset it. For distinct retained drafts, lift draft state to a parent map keyed by recipient ID or store it elsewhere with the same identity.

What a Strong Answer Covers

  • Explain how React preserves state across prop changes.
  • Distinguish resetting a subtree from retaining state by recipient.
Follow-up Interview Question · Which other local state would a key change reset?

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.