You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -455,9 +447,9 @@ You'll see the message in your app's chat box UI. If you have sent a message via
455
447
456
448
## Step 5: Edit a message <aid="step-5"/>
457
449
458
-
If your client makes a typo, or needs to update their original message then they can edit it. To do this, you can extend the functionality of the `ChatBox` component to allow updating of messages. The `useMessages()` hook exposes the [`update()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#update) method of the Chat SDK [messages](/docs/chat/rooms/messages?lang=react) feature.
450
+
If your client makes a typo, or needs to update their original message then they can edit it. To do this, you can extend the functionality of the `ChatBox` component to allow updating of messages. The `useMessages()` hook exposes the [`updateMessage()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#update) method of the Chat SDK [messages](/docs/chat/rooms/messages?lang=react) feature.
459
451
460
-
Expose the `update()` method from the `useMessages()` hook and then add a method to the `ChatBox` component to handle the edit action like so:
452
+
Expose the `updateMessage()` method from the `useMessages()` hook and then add a method to the `ChatBox` component to handle the edit action like so:
461
453
462
454
<Code>
463
455
```react
@@ -483,7 +475,7 @@ function ChatBox() {
483
475
return;
484
476
}
485
477
486
-
update(editingMessage.serial, {text: editText.trim()}, {description: "Message update by user"})
478
+
updateMessage(editingMessage.serial, {text: editText.trim()}, {description: "Message update by user"})
487
479
.then((updatedMsg: Message) => {
488
480
console.log('Message updated:', updatedMsg);
489
481
setEditModalVisible(false);
@@ -499,7 +491,7 @@ function ChatBox() {
499
491
});
500
492
501
493
console.log('Update function completed');
502
-
}, [editingMessage, editText, update]);
494
+
}, [editingMessage, editText, updateMessage]);
503
495
504
496
const handleChange = (newValue: string) => {
505
497
setInputValue(newValue);
@@ -606,7 +598,7 @@ Update the listener provided to the `useMessages()` hook to handle the `ChatMess
606
598
<Code>
607
599
```react
608
600
// ChatApp.tsx - Replace the useMessages hook with the following:
0 commit comments