19 lines
660 B
JavaScript
19 lines
660 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.useUnmount = void 0;
|
|
var React = require("react");
|
|
/**
|
|
* 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
|