Skip to main content

Overview

useUpdateEntity returns a function that updates an entity’s content fields. After a successful update, the entity state inside the nearest EntityProvider is automatically synced with the new data.

Usage Example

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

function EditPost({ entityId }: { entityId: string }) {
  const updateEntity = useUpdateEntity();

  const handleSave = async (newContent: string) => {
    const updated = await updateEntity({
      entityId,
      update: { content: newContent },
    });
    console.log("Updated:", updated.id);
  };

  return <button onClick={() => handleSave("Revised content")}>Save</button>;
}

Parameters

entityId
string
required
The ID of the entity to update.
update.title
string | null
New title. Pass null to clear.
update.content
string | null
New content body. Pass null to clear.
update.attachments
Record<string, any>[]
Replacement attachments array.
update.keywords
string[]
Replacement keywords array.
update.location
{ latitude: number; longitude: number }
New geographic location.
update.metadata
Record<string, any>
Replacement metadata object.
update.mentions
Mention[]
Updated mentions array.

Returns

Entity
Entity
The updated entity. See Entity data model.