This repository has been archived on 2026-02-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
synthetic-consumer-data/context/toast/ToastContext.ts

24 lines
481 B
TypeScript

import { createContext, useContext } from 'react';
export interface Toast {
id: number;
message: string;
}
interface ToastContextType {
showToast: (message: string) => void;
toasts: Toast[];
}
export const ToastContext = createContext<ToastContextType | undefined>(
undefined
);
export const useToast = () => {
const context = useContext(ToastContext);
if (!context) {
throw new Error('useToast must be used within a ToastProvider');
}
return context;
};