Skip to main content

Overview

useFetchCommentReactions returns a function that fetches individual reaction records for a comment. Use this to show “who reacted” lists, optionally filtered by a specific reaction type.

Usage Example

import { useFetchCommentReactions } from "@replyke/react-js";
import { useState } from "react";

function CommentLikers({ commentId }: { commentId: string }) {
  const fetchReactions = useFetchCommentReactions();
  const [reactions, setReactions] = useState([]);

  const load = async () => {
    const res = await fetchReactions({ commentId, page: 1, reactionType: "like" });
    setReactions(res.data);
  };

  return <button onClick={load}>See who liked</button>;
}

Parameters

commentId
string
required
The comment to fetch reactions for.
page
number
required
Page number (1-indexed).
limit
number
Results per page. Default: 20.
reactionType
ReactionType
Filter to a specific reaction type.
sortDir
"asc" | "desc"
Sort direction by creation date. Default: "desc".

Returns

data
Reaction[]
Array of reaction records. Each includes id, userId, reactionType, targetId, targetType, createdAt. The user field is populated when user data is available.
pagination
PaginationMetadata
Pagination metadata for the result set.
  • page — current page number
  • pageSize — number of results returned
  • totalItems — total number of reactions matching the query
  • totalPages — total number of pages
  • hasMore — whether additional pages are available