Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crumb/use-debounce

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crumb/use-debounce

React hook to debounce state updates.

  • 1.0.6
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@crumb/use-debounce

React hook to debounce state updates.

Description

This package is a custom React hook that can be used for debouncing state updates. This is useful when state changes cause large re-renders such as a search box for a long list of items.

Other similar packages exist for debouncing values, such as Nik Mostovoy's use-debounce package, but this package aims to be a very lightweight plugin to easily get up and running without adding lots of extra code bloat.

Installation

# Yarn
yarn add @crumb/use-debounce

# npm
npm install @crumb/use-debounce

Basic Usage

The following is a simple usage showing how the debounced value will be different from the actual value. In an actual application, you will likely use the debounced value in a useMemo hook or as a prop to a memoized component.

import React, { useState } from 'react'
import { useDebounce } from '@crumb/use-debounce'

function Input() {
  const [text, setText] = useState('Hello')
  const value = useDebounce(text, 1000)

  return (
    <div>
      <input
        defaultValue="Hello"
        onChange={event => setText(event.target.value)}
      />

      <p>Actual value: {text}</p>
      <p>Debounce value: {value}</p>
    </div>
  )
}

Keywords

FAQs

Package last updated on 22 Dec 2019

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