// Importing necessary modules from React import React, { createContext } from 'react'; // Importing types for NotificationContext import { NotificationContextType } from './types'; // Creating a context for managing notifications export const NotificationContext = createContext( undefined ); // Custom hook to access the NotificationContext export const useNotification = () => { // Getting the context value const context = React.useContext(NotificationContext); // Throw an error if the hook is used outside of a NotificationProvider if (context === undefined) { throw new Error( 'useNotification must be used within a NotificationProvider' ); } // Return the context return context; };