{"id":13429516,"url":"https://github.com/rehooks/component-size","last_synced_at":"2026-01-14T02:51:57.605Z","repository":{"id":57138839,"uuid":"154727381","full_name":"rehooks/component-size","owner":"rehooks","description":"React hook for determining the size of a component","archived":false,"fork":false,"pushed_at":"2023-02-05T10:55:06.000Z","size":140,"stargazers_count":240,"open_issues_count":18,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-22T04:43:08.979Z","etag":null,"topics":["component","element","hook","react","size"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/rehooks.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":"2018-10-25T19:39:39.000Z","updated_at":"2025-09-09T18:54:06.000Z","dependencies_parsed_at":"2023-02-18T23:01:14.456Z","dependency_job_id":null,"html_url":"https://github.com/rehooks/component-size","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rehooks/component-size","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehooks%2Fcomponent-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehooks%2Fcomponent-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehooks%2Fcomponent-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehooks%2Fcomponent-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehooks","download_url":"https://codeload.github.com/rehooks/component-size/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehooks%2Fcomponent-size/sbom","scorecard":{"id":769233,"data":{"date":"2025-08-18","repo":{"name":"github.com/rehooks/component-size","commit":"36e5057d5746c27669d88093570532b267394f13"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":3.6,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":4,"reason":"Found 7/15 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:46:32.475Z","repository_id":57138839,"created_at":"2025-08-23T01:46:32.475Z","updated_at":"2025-08-23T01:46:32.475Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["component","element","hook","react","size"],"created_at":"2024-07-31T02:00:41.082Z","updated_at":"2026-01-14T02:51:57.587Z","avatar_url":"https://github.com/rehooks.png","language":"JavaScript","readme":"# `@rehooks/component-size`\n\n## Install\n\n```sh\nyarn add @rehooks/component-size\n```\n\n## Usage\n\n```js\nimport { useRef } from 'react'\nimport useComponentSize from '@rehooks/component-size'\n\nfunction MyComponent() {\n  let ref = useRef(null)\n  let size = useComponentSize(ref)\n  // size == { width: 100, height: 200 }\n  let { width, height } = size\n  let imgUrl = `https://via.placeholder.com/${width}x${height}`\n\n  return (\n    \u003cdiv style={{ width: '100%', height: '100%' }}\u003e\n      \u003cimg ref={ref} src={imgUrl} /\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n## ResizeObserver\n\n[Resize Observer](https://developers.google.com/web/updates/2016/10/resizeobserver)\nis the API is used to determine if an element is resized. Browser support is pretty good in Chrome, but is still missing support in other major browsers.\n\n\u003e [Can i use ResizeObserver?](https://caniuse.com/#feat=resizeobserver)\n\n### Polyfill\n\nYou can import the\n[polyfill](https://github.com/que-etc/resize-observer-polyfill) directly from here\n\n```sh\nyarn add resize-observer-polyfill\n```\n\nThen import it in your app:\n\n```js\nimport 'resize-observer-polyfill'\n```\n\nIf you are using Webpack (or similar) you could use [dynamic\nimports](https://webpack.js.org/api/module-methods/#import-), to load the\nPolyfill only if needed. A basic implementation could look something like this:\n\n```js\nloadPolyfills()\n  .then(() =\u003e /* Render React application now that your Polyfills are ready */)\n\n/**\n* Do feature detection, to figure out which polyfills needs to be imported.\n**/\nfunction loadPolyfills() {\n  const polyfills = []\n\n  if (!supportsResizeObserver()) {\n    polyfills.push(import('resize-observer-polyfill'))\n  }\n\n  return Promise.all(polyfills)\n}\n\nfunction supportsResizeObserver() {\n  return (\n    'ResizeObserver' in global \u0026\u0026\n    'ResizeObserverEntry' in global \u0026\u0026\n    'contentRect' in ResizeObserverEntry.prototype\n  )\n}\n```\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehooks%2Fcomponent-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehooks%2Fcomponent-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehooks%2Fcomponent-size/lists"}