React Chat Component Architecture
A React chat widget is built from a tree of small, focused components. This
diagram shows that tree from the root ChatbotApp down to individual buttons,
color-coded by each component's role, and highlights the data-flow path that
makes React's "callbacks up, props down" pattern work. Hover any component to see
its props and state.
Interactive Demo
To embed this MicroSim in your own page, use the following iframe:
1 | |
Overview
Components are grouped by responsibility:
- Container components (dark blue) -
ChatbotApp,MessageList, andInputAreahold state and coordinate their children. - Presentational components (light blue) -
ChatHeader,Message,UserMessage,BotMessage, and theTextMessage/RichMessage/MediaMessagevariants simply render what they are given. - User-interaction components (green) -
TextInput,SendButton,AttachmentButton,QuickReplies, andScrollToBottomcapture user input.
Two orange data-flow edges show the core React pattern:
InputAreareports a new message up toChatbotAppvia theonSendMessagecallback.ChatbotApppasses the updated messages array down toMessageListas props, which triggers a re-render.
Lesson Plan
- Container vs. presentational. Have students explain why state lives in containers and not in the leaf bubbles.
- Follow the data. Trace a typed message from
TextInputall the way to a re-renderedBotMessage, naming every component and the props passed. - Add a feature. Ask where a "message reactions" feature would slot into the tree and which component would own its state.
- Lift state up. Discuss what would break if
InputAreatried to own the conversation history instead ofChatbotApp.