@fruits-chain/react-native-xiaoshu
Version:
React Native UI library
32 lines (26 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
const useSafeHeight = function () {
let {
top = true,
bottom = true
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
const insetTop = top ? insets.top : 0;
const insetBottom = bottom ? insets.bottom : 0;
const dimensionsWindow = (0, _reactNative.useWindowDimensions)();
const [height, setHeight] = (0, _react.useState)(dimensionsWindow.height - insetTop - insetBottom);
(0, _react.useLayoutEffect)(() => {
setHeight(dimensionsWindow.height - insetTop - insetBottom);
}, [dimensionsWindow.height, insetTop, insetBottom]);
return height;
};
var _default = useSafeHeight;
exports.default = _default;
//# sourceMappingURL=useSafeHeight.js.map