Files
flyer-crawler.projectium.com/src/hooks/useModal.tsx

16 lines
505 B
TypeScript

// src/hooks/useModal.tsx
import { useContext } from 'react';
import { ModalContext, ModalContextType } from '../contexts/ModalContext';
/**
* The custom hook that components will use to access the modal context.
* It provides a clean and simple API for interacting with modals.
*/
export const useModal = (): ModalContextType => {
const context = useContext(ModalContext);
if (context === undefined) {
throw new Error('useModal must be used within a ModalProvider');
}
return context;
};