1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports["default"] = void 0;
|
8 | var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
9 | var _react = require("react");
|
10 | var _useLatest = _interopRequireDefault(require("../useLatest"));
|
11 | var _utils = require("../utils");
|
12 | var _isDev = _interopRequireDefault(require("../utils/isDev"));
|
13 | var 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 | };
|
26 | var _default = useUnmount;
|
27 | exports["default"] = _default; |
\ | No newline at end of file |