Feedtack

The useFeedtack hook gives your components programmatic access to Feedtack's UI state. Use it to build custom feedback triggers, integrate with your app's navigation, or respond to Feedtack state changes.

import { useFeedtack } from "feedtack/react";

Return value

interface FeedtackContextValue {
  activatePinMode: () => void;
  deactivatePinMode: () => void;
  isPinModeActive: boolean;
  selectedColor: string;
  setSelectedColor: (color: string) => void;
  pinPalette: readonly string[];
  openModal: () => void;
  closeModal: () => void;
  isModalOpen: boolean;
}
PropertyTypeDescription
activatePinMode() => voidEnter crosshair pin placement mode
deactivatePinMode() => voidExit pin mode
isPinModeActivebooleanWhether pin mode is currently active
selectedColorstringCurrently selected pin color (hex)
setSelectedColor(color: string) => voidChange the pin color
pinPalettereadonly string[]Available pin colors
openModal() => voidOpen the feedback modal
closeModal() => voidClose the feedback modal
isModalOpenbooleanWhether the modal is currently open

Usage

Custom feedback button

function MyFeedbackButton() {
  const { openModal, isModalOpen } = useFeedtack();

  return (
    <button onClick={openModal}>
      {isModalOpen ? "Close Feedback" : "Give Feedback"}
    </button>
  );
}

Trigger pin mode from a menu

function ReviewMenu() {
  const { activatePinMode, isPinModeActive, deactivatePinMode } = useFeedtack();

  return (
    <button onClick={isPinModeActive ? deactivatePinMode : activatePinMode}>
      {isPinModeActive ? "Cancel Pin" : "Drop a Pin"}
    </button>
  );
}

Requirements

useFeedtack must be called inside a <FeedtackProvider>. Calling it outside will throw:

Error: useFeedtack must be used inside <FeedtackProvider>

When disabled is true on the provider, all methods become no-ops and boolean states return false.

On this page