Problem
Build a WhatsApp-like chat.
Requirements
- Populate a list of chats on the left.
- Clicking a chat opens its conversation on the right.
- You can type and send a message.
- Your messages align right; other participants' messages align left.
Hints / Approach
- State:
chats: [{ id, name, messages: [{ id, text, sender, ts }] }]andactiveChatId. - 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.scrollHeightin an effect). - (Bonus) Unread counts, timestamps, simulated replies, and message status ticks.