{"id":15494057,"url":"https://github.com/thomasthiebaud/react-use-size","last_synced_at":"2025-04-13T05:36:18.809Z","repository":{"id":34867744,"uuid":"185643012","full_name":"thomasthiebaud/react-use-size","owner":"thomasthiebaud","description":"A collection of hooks to measure things in React","archived":false,"fork":false,"pushed_at":"2024-06-18T20:27:28.000Z","size":2802,"stargazers_count":69,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T05:57:02.815Z","etag":null,"topics":["hooks","react","react-hooks"],"latest_commit_sha":null,"homepage":"","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/thomasthiebaud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-08T16:29:55.000Z","updated_at":"2024-10-19T12:50:54.000Z","dependencies_parsed_at":"2024-06-18T16:50:10.239Z","dependency_job_id":"4304a0b3-2fb9-4f83-87a1-2618201e6bca","html_url":"https://github.com/thomasthiebaud/react-use-size","commit_stats":{"total_commits":70,"total_committers":4,"mean_commits":17.5,"dds":"0.34285714285714286","last_synced_commit":"be0c81c62252ef28b1392f5961757b70c7743110"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasthiebaud%2Freact-use-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasthiebaud%2Freact-use-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasthiebaud%2Freact-use-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasthiebaud%2Freact-use-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasthiebaud","download_url":"https://codeload.github.com/thomasthiebaud/react-use-size/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670509,"owners_count":21142897,"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","react","react-hooks"],"created_at":"2024-10-02T08:10:55.851Z","updated_at":"2025-04-13T05:36:18.776Z","avatar_url":"https://github.com/thomasthiebaud.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n# react-use-size\n\nA collection of hooks to measure things in React\n\n## Installation\n\n```\nnpm i react-use-size\n// or\nyarn add react-use-size\n```\n\n## Usage\n\n### useWindowSize\n\n```js\nimport { useWindowSize } from \"react-use-size\";\n\nconst YourComponent = () =\u003e {\n  const { height, width } = useWindowSize();\n\n  return (\n    \u003cReact.Fragment\u003e\n      \u003cp\u003eHeight: {height}\u003c/p\u003e\n      \u003cp\u003eWidth: {width}\u003c/p\u003e\n    \u003c/React.Fragment\u003e\n  );\n};\n```\n\n### useComponentSize\n\n```js\nimport { useComponentSize } from \"react-use-size\";\n\nconst YourComponent = () =\u003e {\n  const { ref, height, width } = useComponentSize();\n\n  return (\n    \u003cReact.Fragment\u003e\n      \u003cdiv ref={ref}\u003e\n        Component\n        \u003cp\u003eHeight: {height}\u003c/p\u003e\n        \u003cp\u003eWidth: {width}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/React.Fragment\u003e\n  );\n};\n```\n\n### useBreakpoint\n\n```js\nimport { useBreakpoint } from \"react-use-size\";\n\nconst YourComponent = () =\u003e {\n  const isSmall = useBreakpoint(640);\n\n  if (isSmall) {\n    return \u003cSmallComponent /\u003e\n  } else {\n    return \u003cDefaultComponent /\u003e\n  }\n};\n```\n\n### useBreakpoints\n\n```js\nimport { useBreakpoints } from \"react-use-size\";\n\nconst YourComponent = () =\u003e {\n  const [isSmall, isMedium] = useBreakpoints([640, 1024]);\n\n  if (isSmall) {\n    return \u003cSmallComponent /\u003e\n  } else if(isMedium) {\n    return \u003cMediumComponent /\u003e\n  } else {\n    return \u003cDefaultComponent /\u003e\n  }\n};\n```\n\n## How to contribute?\n\nThis repo enforce commit style so the release process is automatic. Commits must look like:\n\n\u003e SUBJECT: message starting with a lowercase\n\nwhere SUBJECT is one of:\n\n- build\n- ci\n- chore\n- docs\n- feat\n- fix\n- perf\n- refactor\n- revert\n- style\n- test\n\nA commit including `BREAKING CHANGE:` in the body will create a new major release.\n\nMore details about the conventions are available [here](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#summary) and [here](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional).\n\n## Found a problem?\n\nPlease open an issue or submit a PR, we will be more than happy to help\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasthiebaud%2Freact-use-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasthiebaud%2Freact-use-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasthiebaud%2Freact-use-size/lists"}