Overview
useEntityList is the primary hook for building entity feeds. Each call receives a unique listId that namespaces its Redux state, so multiple independent lists can coexist on the same page.
See Fetching Entities for a full guide on using this hook.
Loaded lists stay current with changes the user makes through these hooks: saving an entity to a collection or removing it from one (addToCollection / removeFromCollection of useCollections or useCollectionsActions) updates its saved in every list that carries saved; reacting to an entity (useReactionToggle, useAddReaction, useRemoveReaction) updates its userReaction and reactionCounts; editing it (useUpdateEntity) updates the edited fields; posting a comment through a comment section updates its commentsCount; renaming a collection (updateCollection) updates its name in saved; and deleting a collection (deleteCollection) drops it, and every collection under it, from saved.collections, with isSaved staying true only while another collection is listed. An EntityProvider given an entity from the list follows these updates. They don’t reach an EntityProvider that fetched the entity itself, or entities held by useFetchManyEntitiesWrapper; fetch those again to see the change.
Usage Example
Props
Unique identifier for this list. Used to namespace Redux state. Must be stable across renders.
Optional. A function called for each entity with a
foreignId. Its result is merged into the entity under an infusion key. See Infusing Data.Source and space
By default the list has no source or space filter, so it shows every entity. Theconfig object passed to fetchEntities narrows it:
Only entities from this source, or
"none" for entities with no source. null or left out: no source filter (the default), so entities from any source, or none.Only entities in this space, or
"none" for entities in no space. null or left out: no space filter (the default).null is left out of the request; "none" is sent only when you pass it (see Saying “no value”). createEntity gives the new entity the list’s source and space; a list filtered to "none" creates it with no source or no space.
Reputation
Theconfig object passed to fetchEntities accepts an optional spaceReputation object that opts each row’s embedded author into an added spaceReputation number. Only spaces the viewer can read count: a space they can’t read reads 0 (see Who sees space reputation).
Opt-in. Adds a
spaceReputation number to each row’s embedded author. null or left out: none. Like the rest of config, it applies to this fetch and the loadMore calls after it; a later fetchEntities call without it drops it. This is a context surface, so spaceId accepts "context".Return Values
Entities merged with data from
infuseData. Empty array if infuseData was not provided.The last load failure, or
null. Cleared when the next load starts; loadMore() retries it. Shared by every mounted hook on the same listId. A SublayError.Loads the first page with the given filters, sort, and config, passed as one object:
filters merge into the list’s current filters, sort and config are the list’s settings, and options control this fetch. Debounced by default (800ms). See Fetching Entities for the full parameter reference.Load the next page of entities and append it, or retry the load that failed (a failed first page is retried as the first page). Does nothing before the first
fetchEntities, while a load is running on this list, while a debounced filter change is waiting to be fetched, or when there is nothing more. Never rejects: a failure lands in error.Reload page 1 with the list’s stored filters, sort and config; a debounced filter change still waiting runs now instead. The loaded entities stay until the new first page replaces them. Does nothing before the first
fetchEntities. Never rejects: a failure lands in error.Creates a new entity and inserts it into the list. Accepts
foreignId, title, content, attachments, keywords, location and metadata, plus insertPosition: "first" | "last"; the source and space come from the list. JSON only: it takes no images or files. To create an entity with uploads, use useCreateEntity.Deletes an entity and removes it from the local list state.
Current reaction sort type. Only sent while
sortBy is "top".Current sort direction. Not sent with
"hot" or "controversial", which rank one way only.Current sort type hint for metadata sorts.
The source filter in use (from config): a source id,
"none" (entities with no source), or null when no source filter is set (every entity).
