Last active
March 7, 2024 07:49
-
-
Save Zwiterrion/84905fdd3ba8ee2723813db2f9b8a21f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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