Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5k Solution #17

Open
wants to merge 1 commit into
base: 5k
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.send-button {
background-color: rgb(25, 135, 84);
color: white;
.send-button, .clear-button {
padding: 12px 20px;
margin-left: 10px;
border: none;
Expand All @@ -9,6 +7,15 @@
cursor: pointer;
}

.send-button {
background-color: rgb(25, 135, 84);
color: white;
}

.clear-button {
background-color: rgb(230, 230, 230);
}

.chat-input {
padding: 12px 15px;
border-radius: 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ export function ChatInput({ chatMessages, setChatMessages }) {
setInputText('');
}

function clearMessages() {
setChatMessages([]);

// Here, you could also run:
// localStorage.setItem('messages', JSON.stringify([]));

// However, because chatMessages is being updated, the
// useEffect in the App component will run, and it will
// automatically update messages in localStorage to be [].
}

return (
<div className="chat-input-container">
<input
Expand All @@ -50,6 +61,10 @@ export function ChatInput({ chatMessages, setChatMessages }) {
onClick={sendMessage}
className="send-button"
>Send</button>
<button
onClick={clearMessages}
className="clear-button"
>Clear</button>
</div>
);
}