UNPKG

@react-hook/size

Version:

A React hook for measuring the size of HTML elements including when they change

3 lines (2 loc) 551 B
import{useState as t}from"react";import r from"@react-hook/resize-observer";import e from"@react-hook/passive-layout-effect";export default(i,o)=>{var[f,n]=t(()=>{var t,r,e=i&&"current"in i?i.current:i;return e?[e.offsetWidth,e.offsetHeight]:[null!==(t=null==o?void 0:o.initialWidth)&&void 0!==t?t:0,null!==(r=null==o?void 0:o.initialHeight)&&void 0!==r?r:0]});return e(()=>{var t=i&&"current"in i?i.current:i;t&&n([t.offsetWidth,t.offsetHeight])},[i]),r(i,t=>{var r=t.target;n([r.offsetWidth,r.offsetHeight])}),f}; //# sourceMappingURL=index.mjs.map