# @rc-component/util

> Shared React utilities for rc-component packages.

Latest version **1.13.0** (published 2026-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rc-component/util
pnpm add @rc-component/util
yarn add @rc-component/util
bun add @rc-component/util
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.13.0 |
| Published | 2026-09-01 |
| First published | 2025-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 211.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 671 |
| Maintainers | zombiej, afc163, madccc, peachscript, chenshuai2144 |
| Keywords | react, util |

## Links

- npm: https://www.npmjs.com/package/@rc-component/util
- Repository: https://github.com/react-component/util
- Homepage: https://react-component.github.io/util
- Issues: https://github.com/react-component/util/issues
- npm.io page: https://npm.io/package/@rc-component/util

## Dependencies (2)

- [react-is](https://npm.io/package/react-is.md) ^19.2.7
- [is-mobile](https://npm.io/package/is-mobile.md) ^5.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.13.0 (latest) — 2026-09-01
- 1.12.0 — 2026-07-13
- 1.11.1 — 2026-05-18
- 1.11.0 — 2026-05-15
- 1.10.1 — 2026-04-07
- 1.10.0 — 2026-03-18
- 1.9.0 — 2026-02-06
- 1.8.2 — 2026-02-05
- 1.8.1 — 2026-01-29
- 1.8.0 — 2026-01-29
- 1.7.0 — 2025-12-30
- 1.6.2 — 2025-12-25
- 1.6.1 — 2025-12-25
- 1.6.0 — 2025-12-09
- 1.5.0 — 2025-12-08
- … 9 more at https://npm.io/package/@rc-component/util/versions

## README

<div align="center">
  <h1>@rc-component/util</h1>
  <p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
  <p>🛠️ Shared React utilities for rc-component packages.</p>

  <p>
    <a href="https://npmjs.org/package/@rc-component/util"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/util.svg?style=flat-square"></a>
    <a href="https://npmjs.org/package/@rc-component/util"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/util.svg?style=flat-square"></a>
    <a href="https://github.com/react-component/util/actions/workflows/react-component-ci.yml"><img alt="build status" src="https://github.com/react-component/util/actions/workflows/react-component-ci.yml/badge.svg"></a>
    <a href="https://app.codecov.io/gh/react-component/util"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/util/master.svg?style=flat-square"></a>
    <a href="https://bundlephobia.com/package/@rc-component/util"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/util?style=flat-square"></a>
    <a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
  </p>
</div>

<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>

## Highlights

- Built for React and maintained by the rc-component team.
- Used by Ant Design and other React component libraries.
- Ships TypeScript declarations with both ES module and CommonJS outputs.
- Keeps examples, tests, and preview builds aligned with the package source.

> This package was historically published as `rc-util`. Prefer the scoped package for new code.

## Install

```bash
npm install @rc-component/util
```

## Usage

```tsx | pure
import {
  Portal,
  raf,
  useEvent,
  useLayoutEffect,
  warning,
} from '@rc-component/util';
```

## Examples

Run the local dumi site:

```bash
npm install
npm start
```

Then open `http://localhost:8000`.

## API

The package exposes small, focused helpers used across rc-component and Ant Design packages. Import the public entry when possible, and use subpath imports for specialized DOM, React, or test helpers.

| Area            | Examples                                                                           |
| --------------- | ---------------------------------------------------------------------------------- |
| React hooks     | `useEvent`, `useLayoutEffect`, `useMergedState`, `useState` helpers                |
| React utilities | `Children/toArray`, `composeRef`, `pickAttrs`, `Portal`                            |
| DOM utilities   | `Dom/canUseDom`, `Dom/contains`, `Dom/dynamicCSS`, `Dom/focus`, `getScrollBarSize` |
| Async helpers   | `raf`, `raf.cancel`                                                                |
| Warnings        | `warning`, `noteOnce`, `resetWarned`                                               |
| Tests           | `test/domHook` for DOM prototype spies                                             |

Examples in `docs/examples` cover the commonly used subpath helpers.

## Development

```bash
npm install
npm start
npm test
npm run build
```

The dumi site runs at `http://localhost:8000` by default.

## Release

```bash
npm run prepublishOnly
```

The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.

## License

@rc-component/util is released under the [MIT](./LICENSE) license.

---
_Source: https://npm.io/package/@rc-component/util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
