1import { useState, useCallback } from 'react';
3export function useToast() {
4 const [toasts, setToasts] = useState([]);
6 const showToast = useCallback((message, type = 'info', duration = 5000) => {
7 const id = Date.now() + Math.random();
8 const toast = { id, message, type, duration };
10 setToasts(prev => [...prev, toast]);
15 const hideToast = useCallback((id) => {
16 setToasts(prev => prev.filter(toast => toast.id !== id));