Widget

useFeedback Hook

Control the widget programmatically with the useFeedback hook.

The useFeedback hook provides programmatic control over the widget from any component inside the FeedbackProvider.

import { useFeedback } from "@fasterfixes/react";

function CustomFeedbackButton() {
  const { show, hide, isVisible, startAnnotation } = useFeedback();

  return (
    <button onClick={() => startAnnotation()}>
      Report an issue
    </button>
  );
}

Return values

PropertyTypeDescription
show() => voidShow the widget
hide() => voidHide the widget
isVisiblebooleanWhether the widget is currently visible
startAnnotation() => voidEnter annotation mode (user can click elements)
feedbackItemsFeedbackItem[]All feedback items for the current project
togglePins() => voidToggle visibility of feedback pins on the page
showPinsbooleanWhether pins are currently visible

Custom trigger button

Replace the default floating button with your own UI:

import { useFeedback } from "@fasterfixes/react";

function FeedbackTrigger() {
  const { startAnnotation, feedbackItems } = useFeedback();

  return (
    <div>
      <button onClick={() => startAnnotation()}>
        Leave feedback ({feedbackItems.length})
      </button>
    </div>
  );
}

Toggle pins

Let users show or hide feedback pins on the page:

import { useFeedback } from "@fasterfixes/react";

function PinToggle() {
  const { togglePins, showPins } = useFeedback();

  return (
    <button onClick={togglePins}>
      {showPins ? "Hide" : "Show"} feedback pins
    </button>
  );
}

The useFeedback hook must be used inside a component wrapped by FeedbackProvider.