import { useState, useCallback } from "react"; import { motion as m, AnimatePresence } from "framer-motion"; export const useNotification = () => { const [showNotification, setShowNotification] = useState(false); const [notificationMessage, setNotificationMessage] = useState(""); const show = useCallback( (message) => { setNotificationMessage(message); setShowNotification(true); setTimeout(() => { setShowNotification(false); }, 5000); }, [setNotificationMessage, setShowNotification] ); const NotificationComponent = () => { return ( {showNotification && (
{notificationMessage}
)}
); }; return { Notification: NotificationComponent, show }; };