> ## Documentation Index
> Fetch the complete documentation index at: https://replyke-feat-push-rich-payload-fields.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Fetch Comment

# `useFetchComment`

## Overview

The `useFetchComment` hook allows you to retrieve a specific comment by its ID. It optionally includes the parent comment, making it useful for displaying threaded comment structures or fetching detailed comment data.

## Usage Example

```tsx theme={null}
import { useFetchComment } from "@replyke/react-js";

function CommentDetails({ commentId }: { commentId: string }) {
  const fetchComment = useFetchComment();

  const handleFetchComment = async () => {
    try {
      const { comment, parentComment } = await fetchComment({
        commentId,
        withParent: true,
      });

      console.log("Fetched comment:", comment);
      console.log("Parent comment:", parentComment);
    } catch (error) {
      console.error("Failed to fetch comment:", error.message);
    }
  };

  return <button onClick={handleFetchComment}>Fetch Comment</button>;
}
```

## Parameters & Returns

### Parameters

The hook returns a function that accepts an object with the following fields:

<ParamField path="commentId" type="string" required>
  The ID of the comment to fetch.
</ParamField>

<ParamField path="withParent" type="boolean">
  Whether to include the parent comment.
</ParamField>

### Returns

The function resolves with an object containing the comment and optionally its parent comment:

<ResponseField name="comment" type="Comment">
  The details of the fetched comment.
</ResponseField>

<ResponseField name="parentComment" type="Comment \">
  null\`
</ResponseField>
