micro/packages/web/src/hooks/useToasts.tsx

14 lines
404 B
TypeScript

import { useContext } from 'react';
import { ToastContext } from '../components/toast/toast-wrapper';
export const useToasts = () => {
const createToast = useContext(ToastContext);
if (!createToast) {
// todo: this should be an error, but it seems like it can be undefined.
// maybe due to concurrent rendering? idk shit about fuck.
return () => undefined;
}
return createToast;
};