1 | ;
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = useWillUnmount;
|
5 | var _useUpdatedRef = _interopRequireDefault(require("./useUpdatedRef"));
|
6 | var _react = require("react");
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8 | /**
|
9 | * Attach a callback that fires when a component unmounts
|
10 | *
|
11 | * @param fn Handler to run when the component unmounts
|
12 | * @category effects
|
13 | */
|
14 | function useWillUnmount(fn) {
|
15 | const onUnmount = (0, _useUpdatedRef.default)(fn);
|
16 | (0, _react.useEffect)(() => () => onUnmount.current(), []);
|
17 | } |
\ | No newline at end of file |