main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
362 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import { useRef } from 'react';
|
---|
| 2 | import useEffectOnce from './useEffectOnce';
|
---|
| 3 | var useUnmount = function (fn) {
|
---|
| 4 | var fnRef = useRef(fn);
|
---|
| 5 | // update the ref each render so if it change the newest callback will be invoked
|
---|
| 6 | fnRef.current = fn;
|
---|
| 7 | useEffectOnce(function () { return function () { return fnRef.current(); }; });
|
---|
| 8 | };
|
---|
| 9 | export default useUnmount;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.