UNPKG

@appello/mobile

Version:

Common package with many useful features for mobile development

17 lines (16 loc) 536 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useComponentSize = void 0; const react_1 = require("react"); const useComponentSize = () => { const [size, setSize] = (0, react_1.useState)({ width: 0, height: 0, }); const onLayout = (event) => { const { width, height } = event.nativeEvent.layout; setSize({ width, height }); }; return (0, react_1.useMemo)(() => [size, onLayout], [size, onLayout]); }; exports.useComponentSize = useComponentSize;