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. Every action works in the project of the nearest SublayProvider.
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
Returns
Navigation
Data Fetching
Fetch sub-collections for a given collection and update Redux state.
CRUD Operations
Create a new sub-collection under the specified parent collection. Navigates into the new collection after creation.
Update a collection’s
name, passed next to collectionId. Loaded entity lists that list the collection in saved show the new name.({ collection }: { collection: Collection }) => Promise<{ deletedCollectionIds: string[] } | undefined>
Delete a collection and every collection under it. Once it succeeds, it resolves to
{ deletedCollectionIds } (the deleted collection and every collection under it), and the deleted collections leave Redux state. If the current collection is one of them, navigation moves back to the most recent collection in the history that wasn’t deleted; otherwise it stays where it is. Entity lists loaded with useEntityList that carry saved drop the deleted collections from each entity’s saved.collections, with isSaved staying true only while another collection is listed. Resolves to undefined when the delete fails.Add an entity to a collection by creating a junction table entry. Once it succeeds, loaded entity lists that carry
saved (fetched with include=saved) add the collection, with the name the response gives, to the entity’s saved.collections and set isSaved to true.Remove an entity from a collection. Once it succeeds, loaded entity lists that carry
saved drop the collection from the entity’s saved.collections; isSaved stays true only while another collection is listed.
