Skip to content
File

Blob: src/client/toast/use-toast.ts

typescript12 lines
1import { useContext } from "react";
2import { ToastContext, type ToastContextValue } from "@/client/toast/toast-context";
3 
4export const useToast = (): ToastContextValue => {
5 const value = useContext(ToastContext);
6 if (!value) {
7 throw new Error("useToast must be used within ToastProvider.");
8 }
9 
10 return value;
11};