20 lines
779 B
JavaScript
20 lines
779 B
JavaScript
define(["require", "exports", "react"], function (require, exports, React) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.useUnmount = void 0;
|
|
/**
|
|
* Hook which synchronously executes a callback when the component is about to unmount.
|
|
*
|
|
* @param callback - Function to call during unmount.
|
|
*/
|
|
var useUnmount = function (callback) {
|
|
var unmountRef = React.useRef(callback);
|
|
unmountRef.current = callback;
|
|
React.useEffect(function () { return function () {
|
|
var _a;
|
|
(_a = unmountRef.current) === null || _a === void 0 ? void 0 : _a.call(unmountRef);
|
|
}; }, []);
|
|
};
|
|
exports.useUnmount = useUnmount;
|
|
});
|
|
//# sourceMappingURL=useUnmount.js.map
|