UNPKG

react-native-gesture-handler

Version:

Declarative API exposing native platform touch and gesture system to React Native

20 lines (17 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useIsomorphicLayoutEffect = void 0; var _react = _interopRequireDefault(require("react")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } // code below is modified version of the code found in: // https://github.com/reduxjs/react-redux/blob/7e2fdd4ee2021e4282e12ba9fc722f09124e30cd/src/utils/useIsomorphicLayoutEffect.ts#L36 // React currently throws a warning when using useLayoutEffect on the server. // To get around it, we can conditionally useEffect on the server (no-op) and // useLayoutEffect in the browser. const isDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); // Under React Native, we know that we always want to use useLayoutEffect const isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative'; const useIsomorphicLayoutEffect = exports.useIsomorphicLayoutEffect = isDOM || isReactNative ? _react.default.useLayoutEffect : _react.default.useEffect; //# sourceMappingURL=useIsomorphicLayoutEffect.js.map