Skip to content

Commit

Permalink
Docs: Update message component for clarity
Browse files Browse the repository at this point in the history
Clearly show that deleteMessage and update return promises.
  • Loading branch information
splindsay-92 committed Dec 10, 2024
1 parent ddb322d commit 8c0eac5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,25 @@ const MyComponent = () => {
};

const handleMessageSend = () => {
send({ text: 'Hello, World!' }).then((sentMessage) => setMessages((prevMessages) => [...prevMessages, sentMessage]));
send({ text: 'Hello, World!' }).then((sentMessage) =>
setMessages((prevMessages) => [...prevMessages, sentMessage]),
);
};

const handleMessageDelete = (message: Message) => {
deleteMessage(message, { description: 'deleted by user' });
deleteMessage(message, { description: 'deleted by user' }).then((deletedMessage) =>
console.log('Deleted message: ', deletedMessage),
);
};

const handleUpdateMessage = (message: Message) => {
const newText = prompt('Enter new text');
if (!newText) {
return;
}
update(message, { text: newText }, { description: 'updated by user' });
update(message, { text: newText }, { description: 'updated by user' }).then((updatedMessage) =>
console.log('Updated message: ', updatedMessage),
);
};

return (
Expand Down

0 comments on commit 8c0eac5

Please sign in to comment.