Skip to content

Instantly share code, notes, and snippets.

@Zwiterrion
Last active March 7, 2024 07:49
Show Gist options
  • Save Zwiterrion/84905fdd3ba8ee2723813db2f9b8a21f to your computer and use it in GitHub Desktop.
Save Zwiterrion/84905fdd3ba8ee2723813db2f9b8a21f to your computer and use it in GitHub Desktop.
export function Chat() {
const [messages, setMessages] = useState([]);
const [message, setMessage] = useState("");
return (
<div className="chat">
<div className="messages">
{messages.map((message, idx) => {
return <div
className={`message ${message.name === name ? 'left' : 'right'}`}
key={idx}>
{message.content}
</div>
})}
</div>
<div className="submission-form">
<input
placeholder="Type your message here!"
type="text"
value={message}
onChange={e => setMessage(e.target.value)} />
<button>Send</button>
</div>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment