UNPKG

@magicbell/react-headless

Version:

Hooks to build a notification inbox

28 lines 937 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = useNotificationUnmount; const react_1 = require("react"); /** * Hook that is ran when the component is unmounted. By default marks a * notification as seen. * * @param notification The notification * @param fn Callback function to execute when the component is unmounted * * @example * useNotificationUnmount(notification); */ function useNotificationUnmount(notification, fn) { (0, react_1.useEffect)(() => { return () => { if (fn) fn(notification); else notification.markAsSeen(); }; // TODO: Update code to follow lint suggestions of add missing dependencies, // remove [] or wrap parent component in callback // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } //# sourceMappingURL=useNotificationUnmount.js.map