MCPcopy Create free account
hub / github.com/microsoft/SandDance / useSetInterval

Function useSetInterval

docs/app/js/sanddance-app.js:34806–34831  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34804var _react = require("react");
34805var _useConst = require("./useConst");
34806var useSetInterval = function() {
34807 var intervalIds = (0, _useConst.useConst)({});
34808 _react.useEffect(function() {
34809 return function() {
34810 for(var _i = 0, _a = Object.keys(intervalIds); _i < _a.length; _i++){
34811 var id = _a[_i];
34812 // eslint-disable-next-line @typescript-eslint/no-explicit-any
34813 clearInterval(id);
34814 }
34815 };
34816 }, // useConst ensures this will never change, but react-hooks/exhaustive-deps doesn't know that
34817 [
34818 intervalIds
34819 ]);
34820 return (0, _useConst.useConst)({
34821 setInterval: function(func, duration) {
34822 var id = setInterval(func, duration);
34823 intervalIds[id] = 1;
34824 return id;
34825 },
34826 clearInterval: function(id) {
34827 delete intervalIds[id];
34828 clearInterval(id);
34829 }
34830 });
34831};
34832
34833},{"react":"8ePka","./useConst":"jDC9C","@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"abQLL":[function(require,module,exports) {
34834var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected