Outlook_Addin_LLM/node_modules/@fluentui/react-hooks/lib-commonjs/useMountSync.js

26 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMountSync = void 0;
var React = require("react");
/**
* Hook which synchronously executes a callback once the component has been mounted.
*
* `WARNING` This should only be used if you need to perform an action after the component has been mounted and
* before the browser paints. useMountSync will trigger debug warnings in server-rendered scenarios and should be used
* sparingly.
*
* @deprecated Consider to use React.useEffect() or React.useLayoutEffect() directly based on a use case
*
* @param callback - Function to call once the component has been mounted.
*/
var useMountSync = function (callback) {
var mountRef = React.useRef(callback);
mountRef.current = callback;
// eslint-disable-next-line no-restricted-properties
React.useLayoutEffect(function () {
var _a;
(_a = mountRef.current) === null || _a === void 0 ? void 0 : _a.call(mountRef);
}, []);
};
exports.useMountSync = useMountSync;
//# sourceMappingURL=useMountSync.js.map