useElementSize ​
Hook that observes and returns the width and height of element
typescript
import { useElementSize } from '@siberiacancode/reactuse';
Usage ​
typescript
const { value } = useElementSize(elementRef);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | UseElementSizeTarget | - | The target element to observe. |
initialValue? | UseElementSizeValue | { width: 0, height: 0 } |
Returns
Parameters
Name | Type | Default | Note |
---|---|---|---|
initialValue? | UseElementSizeValue | { width: 0, height: 0 } | The initial size of the element. |