1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.useInterval = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const React = tslib_1.__importStar(require("react"));
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function useInterval(callback, delay) {
|
11 | const savedCallback = React.useRef(() => { });
|
12 | React.useEffect(() => {
|
13 | savedCallback.current = callback;
|
14 | }, [callback]);
|
15 | React.useEffect(() => {
|
16 | function tick() {
|
17 | savedCallback.current();
|
18 | }
|
19 | if (delay !== null) {
|
20 | const id = setInterval(tick, delay);
|
21 | return () => clearInterval(id);
|
22 | }
|
23 | }, [delay]);
|
24 | }
|
25 | exports.useInterval = useInterval;
|
26 |
|
\ | No newline at end of file |