Overview
useFetchManyCommentsWrapper is a stateful wrapper around useFetchManyComments that manages the list, the cursor and the sort for you. It lists one level of a thread: an entity’s top-level comments (entityId) or a comment’s direct replies (parentCommentId). Use it for a custom thread view outside CommentSectionProvider.
The hook doesn’t fetch until entityId or parentCommentId is set. Changing the sort, or any prop, resets the list and fetches from the start.
Nested replies (replyDepth above 0) come back inside each comment’s replies exactly as the server delivers them — the hook doesn’t track them. For per-comment “load more replies”, use CommentSectionProvider with useReplies.
For a user’s comments across entities, use useFetchCommentsByUserIdWrapper.
Usage Example
Parameters
List this comment’s direct replies. With
parentCommentId set, entityId is ignored: the parent decides the entity.Initial sort direction for
"createdAt" and "top"; ignored (not sent) for "controversial", which ranks one way only. Default: "desc".Related data to populate, at every level.
"files" adds the comment’s images and files (requires the files-images bundle).Sort direction for the nested levels. Defaults to the current direction; not sent when the nested sort is
"controversial".Returns
The fetched comments. Each
loadMore appends the next page; a comment already in the list isn’t added twice.true while a page is loading, and before entityId or parentCommentId is first set. When both are removed after one was set, the list is cleared and loading is false.The last failure loading the list. Cleared when the next load starts. Call
loadMore() to retry — hasMore stays true after a failure, and the retry asks for the same page again, including a first page that failed. A SublayError.Loads the next page, or retries the page that failed. Does nothing while a page is loading or when
hasMore is false, and never throws — failures land in error.Reloads from the first page with the current filters and sort. The loaded comments stay until the new first page replaces them. Never rejects — failures land in
error.
