Skip to main content

Overview

useEntityListActions provides the low-level Redux-backed actions that power useEntityList. In most cases you should use useEntityList directly. Use this hook when you need to trigger fetch, create, or delete operations from a component that is separate from the one consuming the list state.

Usage Example

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

function RefreshButton() {
  const { fetchEntities } = useEntityListActions();

  const handleRefresh = async () => {
    await fetchEntities("my-feed", {
      page: 1,
      sortBy: "hot",
      limit: 20,
    });
  };

  return <button onClick={handleRefresh}>Refresh</button>;
}

Return Values

fetchEntities
(listId: string, options: FetchEntitiesOptions) => Promise<Entity[] | null>
Fetches a page of entities and dispatches the result into the Redux list state.
createEntity
(listId: string, options: CreateEntityOptions) => Promise<Entity | undefined>
Creates an entity and inserts it into the specified list.
deleteEntity
(listId: string, options: { entityId: string }) => Promise<void>
Deletes an entity and removes it from the specified list.