20 lines
609 B
JavaScript
20 lines
609 B
JavaScript
import { Async } from '@fluentui/utilities';
|
|
import * as React from 'react';
|
|
/**
|
|
* Hook to provide an Async instance that is automatically cleaned up on dismount.
|
|
*/
|
|
export function useAsync() {
|
|
var asyncRef = React.useRef();
|
|
if (!asyncRef.current) {
|
|
asyncRef.current = new 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
|