UNPKG

nbd-app

Version:

🚀 CLI tool to scaffold full-stack authentication starter projects with React, Node.js, and multiple auth providers (Email, Google, and more)

21 lines (15 loc) • 614 B
import { createContext, useContext, useState } from "react"; const NotificationContext = createContext(); export const useNotification = () => useContext(NotificationContext); export const NotificationProvider = ({ children }) => { const [notification, setNotification] = useState(null); const showNotification = (type, message) => { setNotification({ type, message }); }; const clearNotification = () => setNotification(null); return ( <NotificationContext.Provider value={{ notification, showNotification, clearNotification }}> {children} </NotificationContext.Provider> ); };