main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
532 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import { useEffect, useRef } from 'react';
|
---|
| 2 | var useInterval = function (callback, delay) {
|
---|
| 3 | var savedCallback = useRef(function () { });
|
---|
| 4 | useEffect(function () {
|
---|
| 5 | savedCallback.current = callback;
|
---|
| 6 | });
|
---|
| 7 | useEffect(function () {
|
---|
| 8 | if (delay !== null) {
|
---|
| 9 | var interval_1 = setInterval(function () { return savedCallback.current(); }, delay || 0);
|
---|
| 10 | return function () { return clearInterval(interval_1); };
|
---|
| 11 | }
|
---|
| 12 | return undefined;
|
---|
| 13 | }, [delay]);
|
---|
| 14 | };
|
---|
| 15 | export default useInterval;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.