Files
starface-outlook-sync-addin/node_modules/@fluentui/react-hooks/lib-commonjs/useAsync.js
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

23 lines
732 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAsync = useAsync;
var utilities_1 = require("@fluentui/utilities");
var React = require("react");
/**
* Hook to provide an Async instance that is automatically cleaned up on dismount.
*/
function useAsync() {
var asyncRef = React.useRef(undefined);
if (!asyncRef.current) {
asyncRef.current = new utilities_1.Async();
}
React.useEffect(function () {
return function () {
var _a;
(_a = asyncRef.current) === null || _a === void 0 ? void 0 : _a.dispose();
asyncRef.current = undefined;
};
}, []);
return asyncRef.current;
}
//# sourceMappingURL=useAsync.js.map