Socket
Socket
Sign inDemoInstall

react-use

Package Overview
Dependencies
39
Maintainers
1
Versions
270
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-use

Collection of React Hooks


Version published
Weekly downloads
1.7M
increased by0.9%
Maintainers
1
Install size
7.91 MB
Created
Weekly downloads
 

Package description

What is react-use?

The react-use package is a collection of essential React hooks that provide a variety of functionalities to manage state, lifecycle, and side effects in functional components. It simplifies the process of creating complex components by abstracting common behavior into reusable hooks.

What are react-use's main functionalities?

State Management

Manage state with local storage persistence using useLocalStorage hook.

const [state, setState] = useLocalStorage('my-key', initialValue);

Lifecycle and Side Effects

Handle component lifecycle events with useEffectOnce hook.

useEffectOnce(() => { console.log('Component mounted'); return () => console.log('Component will unmount'); });

Sensors

Access sensor data like battery status using useBattery hook.

const state = useBattery();

Animations

Create animations with useSpring hook.

const [style, play] = useSpring({ from: { opacity: 0 }, to: { opacity: 1 } });

UI State

Control UI state such as fullscreen mode with useFullscreen hook.

const [isFullscreen, toggleFullscreen] = useFullscreen(ref);

Other packages similar to react-use

Readme

Source



👍
react-use





npm package CircleCI master npm downloads demos
Collection of essential React Hooks. Port of libreact.
Translations: 🇨🇳 汉语




npm i react-use












Usage — how to import.
Unlicense — public domain.
Support — add yourself to backer list below.






Contributors








FAQs

Last updated on 22 Jan 2024

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