Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

654 B
Raw Blame
import {
  createContext,
  Dispatch,
  PropsWithChildren,
  SetStateAction,
  useState,
} from "react";

type ChartTooltipSyncContextType = {
  tooltipDate?: Date | null;
  setTooltipDate?: Dispatch<SetStateAction<Date | null | undefined>>;
};

export const ChartTooltipSyncContext =
  createContext<ChartTooltipSyncContextType>({});

export function ChartTooltipSync({ children }: PropsWithChildren) {
  const [tooltipDate, setTooltipDate] = useState<Date | null | undefined>(
    undefined,
  );

  return (
    <ChartTooltipSyncContext.Provider value={{ tooltipDate, setTooltipDate }}>
      {children}
    </ChartTooltipSyncContext.Provider>
  );
}