{"id":21521609,"url":"https://github.com/zzarcon/react-resize-observer-hook","last_synced_at":"2025-08-20T18:32:58.168Z","repository":{"id":34053483,"uuid":"167876868","full_name":"zzarcon/react-resize-observer-hook","owner":"zzarcon","description":"ResizeObserver + React hooks","archived":false,"fork":false,"pushed_at":"2022-12-10T02:13:48.000Z","size":3672,"stargazers_count":103,"open_issues_count":26,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-07T12:41:56.596Z","etag":null,"topics":["hooks","observer","react","react-hooks","resize","resize-observer"],"latest_commit_sha":null,"homepage":"https://zzarcon.github.io/react-resize-observer-hook","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zzarcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-28T00:53:57.000Z","updated_at":"2024-01-04T16:30:13.000Z","dependencies_parsed_at":"2023-01-15T04:30:24.061Z","dependency_job_id":null,"html_url":"https://github.com/zzarcon/react-resize-observer-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzarcon%2Freact-resize-observer-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzarcon%2Freact-resize-observer-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzarcon%2Freact-resize-observer-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzarcon%2Freact-resize-observer-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzarcon","download_url":"https://codeload.github.com/zzarcon/react-resize-observer-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230445926,"owners_count":18227060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","observer","react","react-hooks","resize","resize-observer"],"created_at":"2024-11-24T01:07:44.636Z","updated_at":"2024-12-19T14:07:20.927Z","avatar_url":"https://github.com/zzarcon.png","language":"TypeScript","funding_links":[],"categories":["React"],"sub_categories":["React Components"],"readme":"# react-resize-observer-hook [![Build Status](https://travis-ci.org/zzarcon/react-resize-observer-hook.svg?branch=master)](https://travis-ci.org/zzarcon/react-resize-observer-hook)\n\u003e ResizeObserver + React hooks\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"demo.gif\" alt=\"Logo\" width=\"320\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n## Demo\n\n[zzarcon.github.io/react-resize-observer-hook](https://zzarcon.github.io/react-resize-observer-hook)\n\n## Install\n\n```\nyarn add react-resize-observer-hook\n```\n\n## Usage\n\n```js\nimport {useState, useRef} from 'react';\nimport useResize from 'react-resize-observer-hook';\n\nexport default () =\u003e {\n  const [dimensions, setDimensions] = useState({width: 100, height: 50})\n  const parentRef = useRef(null);\n  \n  useResizeObserver(parentRef, (entry) =\u003e setDimensions({\n    width: entry.width,\n    height: entry.height,\n  }));\n\n  return (\n    \u003cdiv ref={parentRef}\u003e\n      {dimensions.width} x {dimensions.height}\n    \u003c/div\u003e\n  )\n}\n\n```\n\n## API\n\n```typescript\nDOMRectReadOnly {\n  bottom: number;\n  height: number;\n  left: number;\n  right: number;\n  top: number;\n  width: number;\n  x: number;\n  y: number;\n  toJSON(): any;\n}\nObserverCallback = (entry: DOMRectReadOnly) =\u003e void;\nuseResizeObserver = (ref: RefObject\u003cHTMLElement\u003e, callback: ObserverCallback) =\u003e {\n```\n\n## Author\n\n[@zzarcon](https://twitter.com/zzarcon)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzarcon%2Freact-resize-observer-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzarcon%2Freact-resize-observer-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzarcon%2Freact-resize-observer-hook/lists"}