UNPKG

@audira/carbon-react-native

Version:

Build React Native apps with component and shared patterns using Carbon

33 lines (32 loc) 920 B
"use strict"; import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react'; import { ToastContext } from "../../contexts/index.js"; import { Overlay } from "./_overlay/index.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export const ToastProvider = /*#__PURE__*/forwardRef(function ToastProvider({ children }, ref) { const overlayRef = useRef(null), show = useCallback((...args) => { overlayRef.current?.show(...args); }, []), dismiss = useCallback((...args) => { overlayRef.current?.dismiss(...args); }, []); useImperativeHandle(ref, () => { return { show, dismiss }; }, [show, dismiss]); return /*#__PURE__*/_jsxs(ToastContext.Provider, { value: { show, dismiss }, children: [children, /*#__PURE__*/_jsx(Overlay, { ref: overlayRef })] }); }); //# sourceMappingURL=ToastProvider.js.map