Skip to content

useResizeObserver

Dynamically get the size change of Dom elements.

Code demonstration

Click button resize the box to see changes


Basic usageUse ref to set element that needs monitoring.

API

typescript
useResizeObserver(target, callback, {
  box: UseResizeObserverOptions,
})

Params

参数说明类型默认值
targetDOM 节点或者 Ref 对象() => Element | Element | JSX.Element-
options额外的配置项UseResizeObserverOptions-

Options

参数说明类型默认值
box盒模型模式ResizeObserverBoxOptionscontent-box

Source

Source · Document · Demo

Released under the MIT License.