Home
← All questions

WhatsApp-style chat UI | Frontend Machine Coding

MediumPremiumMachine Coding

Frontend Machine Coding interview practice: Build a chat interface with a chat list, conversation view, and message sending.

Problem

Build a WhatsApp-like chat.

Requirements

  1. Populate a list of chats on the left.
  2. Clicking a chat opens its conversation on the right.
  3. You can type and send a message.
  4. Your messages align right; other participants' messages align left.

Hints / Approach

  • State: chats: [{ id, name, messages: [{ id, text, sender, ts }] }] and activeChatId.
  • Sending appends a message with sender: "me" to the active chat (immutably) and clears the input.
  • Auto-scroll the message container to the bottom on new messages (ref.scrollTop = ref.scrollHeight in an effect).
  • (Bonus) Unread counts, timestamps, simulated replies, and message status ticks.
Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium