useIsomorphicLayoutEffect.js 1003 B

1234567891011121314151617
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.useIsomorphicLayoutEffect = void 0;
  4. var _react = require("react");
  5. // React currently throws a warning when using useLayoutEffect on the server.
  6. // To get around it, we can conditionally useEffect on the server (no-op) and
  7. // useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
  8. // subscription callback always has the selector from the latest render commit
  9. // available, otherwise a store update may happen between render and the effect,
  10. // which may cause missed updates; we also must ensure the store subscription
  11. // is created synchronously, otherwise a store update may occur before the
  12. // subscription is created and an inconsistent state may be observed
  13. var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
  14. exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;