useCommentsFetches comments from Hasura backend specified in hasuraUrl on mount and
whenever config.limit or config.offset change.
postIdUseCommentsConfigconst useComments: (hasuraUrl: string,postId: string,config?: UseCommentsConfig | undefined) => UseComentsResult;
UseComentsResultinterface UseComentsResult {comments: Comment[];addComment: ({content,author,}: Pick<Comment, 'content' | 'author'>) => void;refetch: () => void;count: number;loading: boolean;error: UseCommentsError | null;}
Commentexport interface Comment {post_id: string;author: string;content: string;created_at: string;status?: CommentStatus;}
UseCommentsConfigAllows to implement pagination for the comments. Learn more about implementing pagination.
export interface UseCommentsConfig {limit?: number;offset?: number;}
CommentStatusWhen user is adding a new comment it will be in one of four states:
sending — add comment request is still pending.added — the comment was successfully added and is visible for other people.delivered-awaiting-approval — the comment was successfully added, but it's
not yet visible for other people. You can make comments to require approval
before being visible to others. Read more about it
here.failed — adding a comment was unsuccessful.export declare type CommentStatus =| 'sending'| 'added'| 'delivered-awaiting-approval'| 'failed';
UseCommentsErrorinterface UseCommentsError {error: string;details: string;}