Skip to main content

Overview

useFetchCommentReactionsWrapper is a stateful wrapper around useFetchCommentReactions that manages pagination and reaction list state for you. Use it to build “who reacted” UIs for comments — for example, a popover showing users who liked a specific comment. By default the hook does not fetch on mount. Set autoFetch: true to start fetching immediately, or call refetch() manually when you’re ready (e.g., when a popover opens).

Usage Example

Parameters

string
required
The comment to fetch reactions for.
number
Number of reactions per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 comment/invalid-query, never lowered to 100.
ReactionType
Filter to a specific reaction type. When omitted, all reaction types are returned.
"asc" | "desc"
Sort direction by creation date. Default: "desc".
boolean
If true, fetch automatically on mount. Default: false.

Returns

Reaction[]
The current list of fetched reactions. Appended to on each loadMore call.
boolean
true while fetching the initial page or loading more.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. A SublayError.
boolean
true while loadMore() has something to fetch: a next page, or a load that failed.
() => Promise<void>
Load the next page of reactions and append it, or retry the load that failed. With autoFetch off, the first call loads page 1. Does nothing while a load is running or when there is nothing more. Never rejects: a failure lands in error.
() => Promise<void>
Reload from page 1. The loaded reactions stay until the new first page replaces them. Never rejects: a failure lands in error.