UNPKG

amplify-material-ui

Version:

A Material-UI based implementation of aws amplify

13 lines (12 loc) 738 B
import * as React from 'react'; import { NotificationContext } from './use-notification-context'; export var NotificationProvider = function (_a) { var children = _a.children, onShowNotification = _a.onShowNotification; var _b = React.useState(null), notification = _b[0], setNotification = _b[1]; var showNotification = function (message) { var msg = onShowNotification ? onShowNotification(message) : message; setNotification(msg); }; var clearNotification = function () { return setNotification(null); }; return (React.createElement(NotificationContext.Provider, { value: { showNotification: showNotification, clearNotification: clearNotification, notification: notification } }, children)); };