Socket
Socket
Sign inDemoInstall

rc-util

Package Overview
Dependencies
Maintainers
9
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-util

Common Utils For React Component


Version published
Weekly downloads
3.3M
decreased by-10.27%
Maintainers
9
Weekly downloads
 
Created

What is rc-util?

The rc-util npm package is a collection of utility functions and components designed to be used with React components. It provides a set of tools to help with common tasks in React development such as DOM manipulation, event handling, and component management.

What are rc-util's main functionalities?

DOM manipulation

This feature allows you to get the scroll position of an element or the window. It is useful for handling scroll-related logic in your React components.

import { getScroll } from 'rc-util/lib/Dom/scroll';

const scrollPosition = getScroll(window);
console.log(scrollPosition);

Event handling

This feature provides a way to add and remove event listeners. It is particularly useful for setting up event listeners with the capability to easily remove them later, preventing potential memory leaks.

import { addEventListener } from 'rc-util/lib/Dom/addEventListener';

const removeListener = addEventListener(window, 'resize', () => {
  console.log('Window resized');
});

// To remove the event listener
removeListener();

KeyCode utilities

KeyCode utilities provide a convenient set of constants for key codes, which can be used to improve the readability and maintainability of code that involves keyboard event handling.

import KeyCode from 'rc-util/lib/KeyCode';

const isEnterPressed = (event) => {
  return event.keyCode === KeyCode.ENTER;
};

Other packages similar to rc-util

Keywords

FAQs

Package last updated on 17 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc