Outlook_Addin_LLM/node_modules/@fluentui/utilities/lib-amd/useIsomorphicLayoutEffect.js

20 lines
1.1 KiB
JavaScript

define(["require", "exports", "react", "./dom/canUseDOM"], function (require, exports, React, canUseDOM_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useIsomorphicLayoutEffect = void 0;
/**
* React currently throws a warning when using `useLayoutEffect` on the server. To get around it,
* this hook calls `useEffect` on the server (no-op) and `useLayoutEffect` in the browser.
*
* Prefer `useEffect` unless you have a specific need to do something after mount and before paint,
* such as to avoid a render flash for certain operations.
*
* Server-side rendering is detected based on `canUseDOM` from `@fluentui/utilities`.
*
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
*/
// eslint-disable-next-line no-restricted-properties
exports.useIsomorphicLayoutEffect = (0, canUseDOM_1.canUseDOM)() ? React.useLayoutEffect : React.useEffect;
});
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map