useSize ​
A hook that observes size change of an element.
Code demonstration ​
Default usage ​
Pass in the DOM element ​
API ​
typescript
const size = useSize(target)
Params ​
Property | Description | Type | Default |
---|---|---|---|
target | DOM element or ref object | Element | (() => Element) | JSX.Element | - |
Result ​
Property | Description | Type |
---|---|---|
size | Size of the element | Readonly《Ref<{ width: number, height: number } | undefined>> |