Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 2x 153x 153x 2x 151x | // 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;
};
|