Files
new-phone-who-dis/phone/src/ui/hooks/useSnackbar.ts
T
2021-03-02 20:41:25 +01:00

15 lines
359 B
TypeScript

import { useContext } from 'react';
import { SnackbarContext } from '../providers/SnackbarProvider';
export interface IAlert {
message: string;
type: 'success' | 'error' | 'info';
}
interface ISnackBar {
addAlert: ({ message, type }: IAlert) => void;
alert: IAlert | null;
}
export const useSnackbar = (): ISnackBar => useContext(SnackbarContext);