Util screenshot

Util

Author Avatar Theme by React component
Updated: 24 Jul 2025
654 Stars

Common Utils For React Component

Overview

The rc-util library is a robust set of utility functions designed specifically for React components, enhancing the way developers build and manage their applications. This toolkit streamlines common tasks such as managing component lifecycle, handling visibility, and manipulating DOM elements, allowing developers to streamline their workflows and improve code quality.

By providing essential functionalities in a neatly organized package, rc-util empowers developers to focus on building features rather than getting bogged down in boilerplate code. It is particularly beneficial for those who work with complex React applications and need reliable solutions for common challenges.

Features

  • createChainedFunction(…functions): Creates a single function that calls multiple functions in sequence with the given arguments, improving code organization.

  • deprecated(prop: string, instead: string, component: string): Logs a warning message for deprecated props, helping prevent the use of outdated practices.

  • getContainerRenderMixin(config: Object): Generates a mixin that automatically renders a component into a specified container, simplifying component management.

  • getScrollBarSize(fresh?: boolean): Returns the width of the scrollbar, facilitating layout adjustments and ensuring consistency across browsers.

  • guid(): Generates a globally unique identifier for use throughout the current application, ideal for managing component keys.

  • pickAttrs(props: Object): Extracts valid HTML attributes from props for cleaner rendering and easier maintenance.

  • warn(msg: string): A simple wrapper for console warnings to ensure relevant information is easily communicated during development.

  • Dom/addEventListener(target: ReactNode, eventType: string, listener: Function): Provides an enhanced way to add event listeners to DOM nodes with a removal method, promoting better event management.