Overview
useReplies gives you a comment’s replies inside the nearest CommentSectionProvider, and a loadMore function that continues from whatever is already loaded — including replies the section brought in nested with the first page.
It never fetches on its own: call loadMore() (for example from a “View replies” button).
Must be used inside a
CommentSectionProvider. See Comment Section.Usage Example
replyDepth above 0, comments arrive with their first replies already loaded; with the default replyDepth of 0, every comment starts with nothing loaded and the first click fetches its replies.
What a load fetches
The first load of a comment’s replies nests, using the section’sreplyDepth and replyLimit. Later loads fetch plain pages. Every load continues after the replies already shown — including ones the section pre-loaded.
With the provider at replyDepth={2} replyLimit={3} and useReplies({ limit: 10 }):
You can override the rule for a thread or for a single click:
replySortBy / replySortDir / replySortByReaction, which default to the section’s sort), so loading more continues in the same order as the pre-loaded replies.
A request can return at most 500 comments (see Request size limit). If the default first-load nesting would go over it, useReplies lowers the depth until it fits and, outside production builds (in development and in test runs), logs a warning. A replyDepth you pass explicitly is sent as-is.
Props
How many direct replies each load fetches. Default:
10. Can be overridden per call with loadMore({ limit }).Levels of replies to nest on this comment’s first load (
0–5). Defaults to the section’s replyDepth. Later loads don’t nest unless you pass loadMore({ replyDepth }).Return Values
Its loaded replies, in order. Replies the user posted this session are kept out of this list (they’re in
newReplies), even if a later load returns them.Replies the user posted this session, newest first. They stay where they are rather than jumping into
replies.true while a load of this commentId’s replies is in flight. It belongs to the commentId passed: a load still running for another comment doesn’t show here.The last failure loading this
commentId’s replies; a failure for another comment doesn’t show here. Cleared when the next load starts or the section resets (for example on a sort change). Call loadMore() to retry — hasMore stays true after a failure, and the retry asks for the same replies again (including the nesting of a first load). A SublayError.Whether there are replies to load. Before the comment’s replies were ever loaded, this is
true when its repliesCount is more than the replies already shown under it — the user’s own new replies and, for the parent of a highlighted comment, the highlighted reply. After that, it’s the server’s exact hasMore.Loads the next replies, or retries the load that failed. Does nothing while a load is in flight or when
hasMore is false, and never throws — failures land in error.Reloads this comment’s replies from the first page, nested as a first load is. The replies loaded so far stay until the new page replaces them, and the viewer’s own new replies are kept. Never throws — failures land in
error, and loadMore() retries the refetch.
