rc-util

Shared React hooks, ref, DOM, and warning utilities used across rc-component and Ant Design.

Library
npm
v5.44.4
670 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 80
Maintenance 80
Community 72
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
69 /100 Good
Architecture 76
Code Quality 80
Innovation 58
Learning Curve 60

rc-util is a grab-bag of small, focused React utilities — hooks like useEvent, useMergedState, and useLayoutEffect, DOM helpers like canUseDom and dynamicCSS, ref-composition helpers, and a warning/noteOnce dev-time logging pair — extracted so every rc-component-family package (and Ant Design itself) can share the same well-tested primitives instead of reimplementing them.

Rather than a themed or opinionated toolkit, it’s an internal-infrastructure library: most consumers pull it in transitively as a dependency of Ant Design’s rc-* component packages, though any React project can import it directly for the same low-level conveniences (controlled-state hooks, ref merging, SSR-safe DOM checks) it provides them.

What You Get

  • State hooks: useMergedState, useControlledState, useEvent, useDelayState, useSyncState, useLayoutEffect
  • Ref utilities: composeRef, fillRef, useComposeRef, supportRef for merging multiple refs safely
  • DOM helpers: canUseDom, contains, dynamicCSS (inject/remove/update <style> tags), getFocusNodeList, isVisible
  • Dev-time diagnostics: warning/noteOnce for deduplicated console warnings, plus resetWarned for test isolation
  • General helpers: omit, pickAttrs, isEqual, mergeProps, get/set/merge deep object utilities, and raf-based animation scheduling

Common Use Cases

  • Building custom React component libraries that need the same controlled/uncontrolled state pattern as Ant Design components
  • Merging multiple refs (e.g. a forwarded ref plus an internal one) safely across React versions
  • Injecting or updating dynamic <style> tags for CSS-in-JS-adjacent styling needs
  • Adding SSR-safe DOM feature checks (canUseDom, isStyleSupport) to isomorphic React code
  • Emitting deduplicated development warnings for deprecated props or invalid usage without console spam

Under The Hood

Architecture - The package has no single entry class; src/index.ts is a flat re-export barrel over independently testable modules grouped by folder (hooks/, Dom/, React/, Children/, utils/), so each utility (a hook, a DOM check, a ref helper) is its own small file with its own test, and consumers tree-shake only what they import. Cross-cutting concerns like ref merging (ref.ts) and controlled-state (useMergedState/useControlledState) are implemented once here and re-exported for every rc-component sibling package (rc-select, rc-table, rc-virtual-list, etc.) to depend on identically. Tech Stack - TypeScript with minimal runtime dependencies (is-mobile, react-is), built via the father build tool (rc-component’s shared tooling) into ES/CJS output with dumi-generated docs; React itself is a peer dependency, not bundled. Code Quality - A large tests/ directory mirrors nearly every source file 1:1 (including a hooks-17.test.tsx variant for React 17 compatibility), giving strong regression coverage for a library whose consumers span the entire Ant Design component tree; some exports like useMergedState are explicitly marked @deprecated in favor of newer alternatives (useControlledState), showing an actively curated, versioned API rather than accumulated cruft. API Design - Everything is a flat, individually-importable named export (import { useEvent, canUseDom } from '@rc-component/util') rather than a monolithic default object, so consumers only pull in the specific hook or helper they need; deprecation notices in JSDoc guide migration without breaking existing imports.

Used by 5 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
99%
Other

LobeHub

AI Assistants · Automation · Productivity

82,864

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,377

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 5 days ago
JavaScript
26%
AGPL 3.0

Omnivore

Bookmarks Archiving · Knowledge Management · Note Taking

16,265

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
90
Repo Health
74
Technical
65
Dependency
Built with
JavaScript 26%
TypeScript 25%
HTML 19%
Updated 5 days ago
TypeScript
89%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,048

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 89%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers