useSize
A hook to subscribe DOM element size change.
The API is different from ahooks.
Examples
Basic usage
API
const size = useSize(target);
Params
| Property | Description | Type | Default |
|---|---|---|---|
| target | DOM element or Ref Object | HTMLElement | (() => HTMLElement) | MutableRefObject | - |
| options | Object | - |
Options
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| onChange | Function | undefined | size change callback |
Result
| Property | Description | Type |
|---|---|---|
| size | size of the DOM | { width: number, height: number } |