UNPKG

910 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports["default"] = void 0;
8var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9var _react = require("react");
10var _useLatest = _interopRequireDefault(require("../useLatest"));
11var _utils = require("../utils");
12var _isDev = _interopRequireDefault(require("../utils/isDev"));
13var useUnmount = function useUnmount(fn) {
14 if (_isDev["default"]) {
15 if (!(0, _utils.isFunction)(fn)) {
16 console.error("useUnmount expected parameter is a function, got ".concat((0, _typeof2["default"])(fn)));
17 }
18 }
19 var fnRef = (0, _useLatest["default"])(fn);
20 (0, _react.useEffect)(function () {
21 return function () {
22 fnRef.current();
23 };
24 }, []);
25};
26var _default = useUnmount;
27exports["default"] = _default;
\No newline at end of file