
A hook that uses Resize Observer API to monitor changes in the size of an element.
npm install resize-observer-hook
import React from 'react'
import useResizeObserver from 'resize-observer-hook'
const App = () => {
const [ref, width, height] = useResizeObserver()
return (
{width} X {height}
)
}
You can add multiple ResizeObserverBoxOptions to the useResizeObserver like this ->
const [ref,width,height] = useResizeObserver("borderBoxSize");
ResizeObserverBoxOptions that are supported currently in the library ->
Note ⚠️ - Some options aren't supported in some broswers so if you provide any option that is not being supported in your current browser, it will automatically use contentRect to calculate height and width of the observed element.
See more details over here -> https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry

You can help this library to grow by contributing here. Pick any issue or open one. Let us know what you are working on and ask your questions in the issues itself :)
The package is made up of 2 main folders:
To setup and run a local copy:
https://github.com/Gautam-Arora24/resize-observer-hook.gitnpm install in the root foldernpm install in the example foldernpm start in the root.npm start in the example folder.When you're done working on your changes, submit a PR with the details and include a screenshot if you've changed anything visually.
MIT © Gautam-Arora24, and the contributors.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
$ claude mcp add resize-observer-hook \
-- python -m otcore.mcp_server <graph>