{"id":13601944,"url":"https://github.com/react-component/util","last_synced_at":"2026-04-07T10:00:38.906Z","repository":{"id":27162397,"uuid":"30631815","full_name":"react-component/util","owner":"react-component","description":"Common Utils For React Component","archived":false,"fork":false,"pushed_at":"2026-03-20T21:03:24.000Z","size":856,"stargazers_count":667,"open_issues_count":82,"forks_count":198,"subscribers_count":10,"default_branch":"master","last_synced_at":"2026-03-23T20:56:07.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"util.vercel.app","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/react-component.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-02-11T05:14:59.000Z","updated_at":"2026-03-18T03:02:17.000Z","dependencies_parsed_at":"2024-02-08T04:25:56.345Z","dependency_job_id":"975f7c5f-8dfe-4325-a3ba-ee54df9710a8","html_url":"https://github.com/react-component/util","commit_stats":{"total_commits":401,"total_committers":40,"mean_commits":10.025,"dds":0.4214463840399002,"last_synced_commit":"102cf34f04b721f82ae271e6cbe9607b92d5e55b"},"previous_names":[],"tags_count":234,"template":false,"template_full_name":null,"purl":"pkg:github/react-component/util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-component%2Futil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-component%2Futil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-component%2Futil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-component%2Futil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-component","download_url":"https://codeload.github.com/react-component/util/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-component%2Futil/sbom","scorecard":{"id":765423,"data":{"date":"2025-08-11","repo":{"name":"github.com/react-component/util","commit":"62e1415639b339acced085433f845603abdc6f37"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.6,"checks":[{"name":"Code-Review","score":2,"reason":"Found 6/24 approved changesets -- score normalized to 2","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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:16","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:17","Warn: no topLevel permission defined: .github/workflows/codeql.yml:1","Warn: no topLevel permission defined: .github/workflows/react-component-ci.yml:1","Warn: topLevel 'contents' permission set to 'write': .github/workflows/site-deploy.yml:9","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/codeql.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/react-component-ci.yml:5: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/react-component-ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/site-deploy.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/site-deploy.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/site-deploy.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/react-component/util/site-deploy.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/site-deploy.yml:25","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   1 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: SAST configuration detected: CodeQL","Info: all commits (18) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T00:37:52.929Z","repository_id":27162397,"created_at":"2025-08-23T00:37:52.929Z","updated_at":"2025-08-23T00:37:52.929Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31213708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-30T15:24:02.938Z","status":"ssl_error","status_checked_at":"2026-03-30T15:23:44.804Z","response_time":138,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-01T18:01:10.399Z","updated_at":"2026-04-07T10:00:38.893Z","avatar_url":"https://github.com/react-component.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","JavaScript"],"sub_categories":[],"readme":"# rc-util\n\nCommon Utils For React Component.\n\n[![NPM version][npm-image]][npm-url]\n[![npm download][download-image]][download-url]\n[![build status][github-actions-image]][github-actions-url]\n[![Codecov][codecov-image]][codecov-url]\n[![bundle size][bundlephobia-image]][bundlephobia-url]\n[![dumi][dumi-image]][dumi-url]\n\n[npm-image]: http://img.shields.io/npm/v/rc-util.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/rc-util\n[travis-image]: https://img.shields.io/travis/react-component/util/master?style=flat-square\n[travis-url]: https://travis-ci.com/react-component/util\n[github-actions-image]: https://github.com/react-component/util/actions/workflows/react-component-ci.yml/badge.svg\n[github-actions-url]: https://github.com/react-component/util/actions/workflows/react-component-ci.yml\n[codecov-image]: https://img.shields.io/codecov/c/github/react-component/util/master.svg?style=flat-square\n[codecov-url]: https://app.codecov.io/gh/react-component/util\n[david-url]: https://david-dm.org/react-component/util\n[david-image]: https://david-dm.org/react-component/util/status.svg?style=flat-square\n[david-dev-url]: https://david-dm.org/react-component/util?type=dev\n[david-dev-image]: https://david-dm.org/react-component/util/dev-status.svg?style=flat-square\n[download-image]: https://img.shields.io/npm/dm/rc-util.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rc-util\n[bundlephobia-url]: https://bundlephobia.com/package/rc-util\n[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-util\n[dumi-url]: https://github.com/umijs/dumi\n[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square\n\n## Install\n\n[![rc-util](https://nodei.co/npm/rc-util.png)](https://npmjs.org/package/rc-util)\n\n## API\n\n### createChainedFunction\n\n\u003e (...functions): Function\n\nCreate a function which will call all the functions with it's arguments from left to right.\n\n```jsx|pure\nimport createChainedFunction from 'rc-util/lib/createChainedFunction';\n```\n\n### deprecated\n\n\u003e (prop: string, instead: string, component: string): void\n\nLog an error message to warn developers that `prop` is deprecated.\n\n```jsx|pure\nimport deprecated from 'rc-util/lib/deprecated';\n```\n\n### getContainerRenderMixin\n\n\u003e (config: Object): Object\n\nTo generate a mixin which will render specific component into specific container automatically.\n\n```jsx|pure\nimport getContainerRenderMixin from 'rc-util/lib/getContainerRenderMixin';\n```\n\nFields in `config` and their meanings.\n\n| Field         | Type                         | Description                                                                | Default |\n| ------------- | ---------------------------- | -------------------------------------------------------------------------- | ------- |\n| autoMount     | boolean                      | Whether to render component into container automatically                   | true    |\n| autoDestroy   | boolean                      | Whether to remove container automatically while the component is unmounted | true    |\n| isVisible     | (instance): boolean          | A function to get current visibility of the component                      | -       |\n| isForceRender | (instance): boolean          | A function to determine whether to render popup even it's not visible      | -       |\n| getComponent  | (instance, extra): ReactNode | A function to get the component which will be rendered into container      | -       |\n| getContainer  | (instance): HTMLElement      | A function to get the container                                            |         |\n\n### Portal\n\nRender children to the specific container;\n\n```jsx|pure\nimport Portal from 'rc-util/lib/Portal';\n```\n\nProps:\n\n| Prop         | Type            | Description                     | Default |\n| ------------ | --------------- | ------------------------------- | ------- |\n| children     | ReactChildren   | Content render to the container | -       |\n| getContainer | (): HTMLElement | A function to get the container | -       |\n\n### getScrollBarSize\n\n\u003e (fresh?: boolean): number\n\nGet the width of scrollbar.\n\n```jsx|pure\nimport getScrollBarSize from 'rc-util/lib/getScrollBarSize';\n```\n\n### guid\n\n\u003e (): string\n\nTo generate a global unique id across current application.\n\n```jsx|pure\nimport guid from 'rc-util/lib/guid';\n```\n\n### pickAttrs\n\n\u003e (props: Object): Object\n\nPick valid HTML attributes and events from props.\n\n```jsx|pure\nimport pickAttrs from 'rc-util/lib/pickAttrs';\n```\n\n### warn\n\n\u003e (msg: string): void\n\nA shallow wrapper of `console.warn`.\n\n```jsx|pure\nimport warn from 'rc-util/lib/warn';\n```\n\n### warning\n\n\u003e (valid: boolean, msg: string): void\n\nA shallow wrapper of [warning](https://github.com/BerkeleyTrue/warning), but only warning once for the same message.\n\n```jsx|pure\nimport warning, { noteOnce } from 'rc-util/lib/warning';\n\nwarning(false, '[antd Component] test hello world');\n\n// Low level note\nnoteOnce(false, '[antd Component] test hello world');\n```\n\n### Children\n\nA collection of functions to operate React elements' children.\n\n#### Children/mapSelf\n\n\u003e (children): children\n\nReturn a shallow copy of children.\n\n```jsx|pure\nimport mapSelf from 'rc-util/lib/Children/mapSelf';\n```\n\n#### Children/toArray\n\n\u003e (children: ReactNode[]): ReactNode[]\n\nConvert children into an array.\n\n```jsx|pure\nimport toArray from 'rc-util/lib/Children/toArray';\n```\n\n### Dom\n\nA collection of functions to operate DOM elements.\n\n#### Dom/addEventlistener\n\n\u003e (target: ReactNode, eventType: string, listener: Function): { remove: Function }\n\nA shallow wrapper of [add-dom-event-listener](https://github.com/yiminghe/add-dom-event-listener).\n\n```jsx|pure\nimport addEventlistener from 'rc-util/lib/Dom/addEventlistener';\n```\n\n#### Dom/canUseDom\n\n\u003e (): boolean\n\nCheck if DOM is available.\n\n```jsx|pure\nimport canUseDom from 'rc-util/lib/Dom/canUseDom';\n```\n\n#### Dom/class\n\nA collection of functions to operate DOM nodes' class name.\n\n- `hasClass(node: HTMLElement, className: string): boolean`\n- `addClass(node: HTMLElement, className: string): void`\n- `removeClass(node: HTMLElement, className: string): void`\n\n```jsx|pure\nimport cssClass from 'rc-util/lib/Dom/class;\n```\n\n#### Dom/contains\n\n\u003e (root: HTMLElement, node: HTMLElement): boolean\n\nCheck if node is equal to root or in the subtree of root.\n\n```jsx|pure\nimport contains from 'rc-util/lib/Dom/contains';\n```\n\n#### Dom/css\n\nA collection of functions to get or set css styles.\n\n- `get(node: HTMLElement, name?: string): any`\n- `set(node: HTMLElement, name?: string, value: any) | set(node, object)`\n- `getOuterWidth(el: HTMLElement): number`\n- `getOuterHeight(el: HTMLElement): number`\n- `getDocSize(): { width: number, height: number }`\n- `getClientSize(): { width: number, height: number }`\n- `getScroll(): { scrollLeft: number, scrollTop: number }`\n- `getOffset(node: HTMLElement): { left: number, top: number }`\n\n```jsx|pure\nimport css from 'rc-util/lib/Dom/css';\n```\n\n#### Dom/focus\n\nA collection of functions to operate focus status of DOM node.\n\n- `saveLastFocusNode(): void`\n- `clearLastFocusNode(): void`\n- `backLastFocusNode(): void`\n- `getFocusNodeList(node: HTMLElement): HTMLElement[]` get a list of focusable nodes from the subtree of node.\n- `limitTabRange(node: HTMLElement, e: Event): void`\n\n```jsx|pure\nimport focus from 'rc-util/lib/Dom/focus';\n```\n\n#### Dom/support\n\n\u003e { animation: boolean | Object, transition: boolean | Object }\n\nA flag to tell whether current environment supports `animationend` or `transitionend`.\n\n```jsx|pure\nimport support from 'rc-util/lib/Dom/support';\n```\n\n### KeyCode\n\n\u003e Enum\n\nEnum of KeyCode, please check the [definition](https://github.com/react-component/util/blob/master/src/KeyCode.ts) of it.\n\n```jsx|pure\nimport KeyCode from 'rc-util/lib/KeyCode';\n```\n\n#### KeyCode.isTextModifyingKeyEvent\n\n\u003e (e: Event): boolean\n\nWhether text and modified key is entered at the same time.\n\n#### KeyCode.isCharacterKey\n\n\u003e (keyCode: KeyCode): boolean\n\nWhether character is entered.\n\n### ScrollLocker\n\n\u003e ScrollLocker\u003c{lock: (options: {container: HTMLElement}) =\u003e void, unLock: () =\u003e void}\u003e\n\nimprove shake when page scroll bar hidden.\n\n`ScrollLocker` change body style, and add a class `ant-scrolling-effect` when called, so if you page look abnormal, please check this;\n\n```js\nimport ScrollLocker from 'rc-util/lib/Dom/scrollLocker';\n\nconst scrollLocker = new ScrollLocker();\n\n// lock\nscrollLocker.lock()\n\n// unLock\nscrollLocker.unLock()\n```\n\n## License\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-component%2Futil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-component%2Futil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-component%2Futil/lists"}