> ## 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 Create Report

# `useCreateReport`

## Overview

The `useCreateReport` hook allows users to report inappropriate or problematic content. It requires a `type` parameter to specify whether you're reporting comments or entities, and returns a specialized function for that type.

## Usage Example

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

function CommentReportButton({ commentId }: { commentId: string }) {
  const createCommentReport = useCreateReport({ type: "comment" });

  const handleReport = async () => {
    try {
      await createCommentReport({
        targetId: commentId,
        reason: "spam",
        details: "This comment contains spam links."
      });

      console.log("Comment report created successfully.");
    } catch (error) {
      console.error("Failed to create report:", error.message);
    }
  };

  return <button onClick={handleReport}>Report Comment</button>;
}

function EntityReportButton({ entityId }: { entityId: string }) {
  const createEntityReport = useCreateReport({ type: "entity" });

  const handleReport = async () => {
    try {
      await createEntityReport({
        targetId: entityId,
        reason: "harassment",
        details: "This entity contains inappropriate content."
      });

      console.log("Entity report created successfully.");
    } catch (error) {
      console.error("Failed to create report:", error.message);
    }
  };

  return <button onClick={handleReport}>Report Entity</button>;
}
```

## Parameters & Returns

### Hook Parameters

The hook accepts an object with the following field:

| Parameter | Type                    | Required | Description                                       |
| --------- | ----------------------- | -------- | ------------------------------------------------- |
| `type`    | `"comment" \| "entity"` | Yes      | Specifies whether to report comments or entities. |

### Returns

The hook returns a single function based on the type specified:

* **For `type: "comment"`**: Returns `createCommentReport` function
* **For `type: "entity"`**: Returns `createEntityReport` function

### Function Parameters

Both returned functions accept the same parameters:

<ResponseField name="targetId" type="string">
  Yes
</ResponseField>

<ResponseField name="reason" type="ReportReasonKey">
  Yes
</ResponseField>

<ResponseField name="details" type="string">
  No
</ResponseField>
