This is a small, focused React component library that wraps the native ResizeObserver API. It provides a declarative component (`<ResizeObserver>`) that can observe a single child element for size changes, supporting both direct children and render-prop patterns for cases where the observed element is not the immediate child. A `Collection` component uses React context and microtask batching to aggregate multiple resize events from child observers into a single callback, improving performance when many elements are observed. The library also exports a `useResizeObserver` hook for imperative use. Internally, it manages a single shared `ResizeObserver` instance with a map of element-to-callback sets, ensuring efficient resource usage. The code is clean, well-typed, and properly tested, making it a reliable building block for responsive UIs. As part of the Ant Design ecosystem, it follows established patterns and integrates smoothly with other @rc-component packages.
A library of custom React hooks for common DOM events, including hover, focus, click outside, touch, mouse position, window resize, and element resize via ResizeObserver. Each hook is an independent module that returns state and event handler bindings, following a consistent pattern of using `useMemo` for the bind object. The `useResizeObserver` hook demonstrates good lifecycle management by using `requestAnimationFrame` to debounce updates and cleaning up the observer. The `useClickOutside` hook supports multiple refs and properly cleans up event listeners. The library is built with TypeScript and uses the now-deprecated Pika build system for packaging. Tests are provided with Jest and React Testing Library. The codebase is simple and well-structured but has not seen active development since around 2020, and the build tooling is outdated.