UNPKG

notistack-v2-maintained

Version:

Highly customizable notification snackbars (toasts) that can be stacked on top of each other

16 lines (15 loc) 589 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = useEventCallback; /** * @link https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/utils/useEventCallback.js */ const react_1 = require("react"); const useEnhancedEffect = typeof window !== "undefined" ? react_1.useLayoutEffect : react_1.useEffect; function useEventCallback(fn) { const ref = (0, react_1.useRef)(fn); useEnhancedEffect(() => { ref.current = fn; }); return (0, react_1.useCallback)((...args) => (0, ref.current)(...args), []); }