Socket
Socket
Sign inDemoInstall

rc-util

Package Overview
Dependencies
0
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-util

Common Utils For React Component


Version published
Weekly downloads
3.3M
increased by3.61%
Maintainers
1
Created
Weekly downloads
 

Package description

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

Readme

Source

rc-util


Common Utils For React Component

NPM version SPM version gemnasium deps node version npm download

install

rc-util

Usage

var rcUtil = require('rc-util');
console.log(rcUtil.classSet({x:1,y:0}));

API

classSet:function

http://facebook.github.io/react/docs/class-name-manipulation.html

shallowEqual:function

KeyCode:enum

enum of KeyCode

KeyCode.ENTER
KeyCode.DOWN

guid:function

return string represent a global unique id across current application

createChainedFunction:function

Dom.addEventListener:function

Dom.contains:function

Children.toArray

transform React Children into Array type

License

rc-util is released under the MIT license.

Keywords

FAQs

Last updated on 13 Mar 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc