Skip to main content

Overview

useCollectionsActions exposes every collection action as a standalone callable function. It is used internally by useCollections but can also be used directly when you need fine-grained control over collection operations without the navigation state.
For most use cases, prefer useCollections — it combines these actions with navigation state. Use useCollectionsActions only when you need to perform actions independently of a navigation context.

Usage Example

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

function QuickSaveButton({ entityId, collectionId, projectId }) {
  const { addToCollection } = useCollectionsActions();

  return (
    <button onClick={() => addToCollection({ projectId, collectionId, entityId })}>
      Save
    </button>
  );
}

Returns

openCollection
(collection: Collection) => void
Push a collection onto the Redux navigation stack.
goBack
() => void
Pop the current collection from the navigation stack.
goToRoot
() => void
Reset navigation to the root collection.

Data Fetching

fetchRootCollection
({ projectId }: { projectId: string }) => Promise<void>
Fetch and set the user’s root collection in Redux state.
fetchSubCollections
({ projectId, collectionId }: { projectId: string; collectionId: string }) => Promise<void>
Fetch sub-collections for a given collection and update Redux state.

CRUD Operations

createCollection
({ projectId, parentCollectionId, collectionName }: ...) => Promise<void>
Create a new sub-collection under the specified parent collection. Navigates into the new collection after creation.
updateCollection
({ projectId, collectionId, update }: ...) => Promise<void>
Update a collection’s name.
deleteCollection
({ projectId, collection }: ...) => Promise<void>
Delete a collection. Updates Redux state to navigate back to the parent.
addToCollection
({ projectId, collectionId, entityId }: ...) => Promise<void>
Add an entity to a collection by creating a junction table entry.
removeFromCollection
({ projectId, collectionId, entityId }: ...) => Promise<void>
Remove an entity from a collection.

Utility

resetCollections
() => void
Clear all collections state from Redux (e.g., on sign-out).