import { createContext } from 'react'; import { NotificationPayload } from './types'; export type NotificationContextType = { notifications: NotificationPayload[]; addNotification: (notification: NotificationPayload) => void; takeNotification: () => NotificationPayload | void; resetNotifications: () => void; }; /** * Context for the notification state and modifiers * * @example // display notifications * import { useNotificationContext } from 'mv-tmp'; * * const App = () => { * const { notifications } = useNotificationContext(); * return ( * * ); * }; * * @example // reset notifications * import { useNotificationContext } from 'mv-tmp'; * * const ResetNotificationsButton = () => { * const { resetNotifications } = useNotificationContext(); * return ( * * ); * }; */ export const NotificationContext = createContext({ notifications: [], addNotification: () => {}, takeNotification: () => {}, resetNotifications: () => {}, });