@scrumble-nl/react-quick-toaster
Version:
A quick and easy wrapper around react-bootstrap toasters, you can toast from anywhere in your application with a few simple steps.
10 lines (9 loc) • 505 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext } from 'react';
import { ToastContext } from './toast-provider';
export const ToastConsumer = ({ children }) => (_jsx(ToastContext.Consumer, { children: context => children(context) }));
export const withToaster = (Comp) => (props) => _jsx(ToastConsumer, { children: context => _jsx(Comp, Object.assign({ toaster: context }, props)) });
export const useToaster = () => {
const { add } = useContext(ToastContext);
return add;
};