Skip to main content

Overview

Returns an async function that patches an existing message’s content. The updated message is dispatched to Redux on success. The editedAt field is set by the server and reflects the time of the most recent edit.
Requires ChatProvider in the component tree.

Usage Example

import { useEditMessage } from "@replyke/react-js";

function EditMessageForm({
  conversationId,
  messageId,
  currentContent,
}: {
  conversationId: string;
  messageId: string;
  currentContent: string;
}) {
  const edit = useEditMessage();
  const [text, setText] = useState(currentContent);

  const handleSave = async () => {
    await edit({ conversationId, messageId, content: text });
  };

  return (
    <div>
      <input value={text} onChange={(e) => setText(e.target.value)} />
      <button onClick={handleSave}>Save</button>
    </div>
  );
}

Parameters

The hook returns a function. That function accepts:
conversationId
string
required
The ID of the conversation that contains the message.
messageId
string
required
The ID of the message to edit.
content
string
New text content.
gif
GifData | null
New or cleared GIF attachment.
mentions
Mention[]
Updated mentions list.
metadata
Record<string, any>
Updated metadata.

Returns

ChatMessage
ChatMessage
The updated ChatMessage returned by the server.

Notes

  • Other participants see the update in real-time via the message:updated socket event, which is handled automatically by ChatProvider.
  • For integration guidance, see Chat: Messages.