UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

34 lines 1.2 kB
import { useCallback } from "react"; import useProject from "../projects/useProject"; import axios from "../../config/axios"; function useFetchCommentReactions() { const { projectId } = useProject(); const fetchCommentReactions = useCallback(async (props) => { const { commentId, page, limit = 20, reactionType, sortDir = "desc" } = props; if (page === 0) { throw new Error("Can't fetch reactions with page 0"); } if (limit === 0) { throw new Error("Can't fetch with limit 0"); } if (!projectId) { throw new Error("No project specified"); } if (!commentId) { throw new Error("No comment ID provided"); } const params = { page, limit, sortDir, }; if (reactionType) { params.reactionType = reactionType; } const response = await axios.get(`/${projectId}/comments/${commentId}/reactions`, { params }); return response.data; }, [projectId]); return fetchCommentReactions; } export default useFetchCommentReactions; //# sourceMappingURL=useFetchCommentReactions.js.map