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

react-debounce-input

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-debounce-input

React component that renders Input with debounced onChange

  • 3.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is react-debounce-input?

The react-debounce-input package provides a React component that debounces the input value change events. This is useful for scenarios where you want to limit the rate at which a function is executed, such as when making API calls based on user input.

What are react-debounce-input's main functionalities?

Basic Debounced Input

This example demonstrates a basic usage of the DebounceInput component. The input value is debounced with a timeout of 300 milliseconds, meaning the onChange event will only be triggered if the user stops typing for 300 milliseconds.

import React, { useState } from 'react';
import { DebounceInput } from 'react-debounce-input';

function App() {
  const [value, setValue] = useState('');

  return (
    <div>
      <DebounceInput
        minLength={2}
        debounceTimeout={300}
        onChange={(event) => setValue(event.target.value)}
      />
      <p>Value: {value}</p>
    </div>
  );
}

export default App;

Debounced Input with Min Length

This example shows how to use the DebounceInput component with a minimum length requirement. The onChange event will only be triggered if the input value has at least 5 characters and the user stops typing for 500 milliseconds.

import React, { useState } from 'react';
import { DebounceInput } from 'react-debounce-input';

function App() {
  const [value, setValue] = useState('');

  return (
    <div>
      <DebounceInput
        minLength={5}
        debounceTimeout={500}
        onChange={(event) => setValue(event.target.value)}
      />
      <p>Value: {value}</p>
    </div>
  );
}

export default App;

Debounced Input with Element

This example demonstrates how to use the DebounceInput component with a different HTML element, such as a textarea. The input value is debounced with a timeout of 300 milliseconds.

import React, { useState } from 'react';
import { DebounceInput } from 'react-debounce-input';

function App() {
  const [value, setValue] = useState('');

  return (
    <div>
      <DebounceInput
        element="textarea"
        minLength={2}
        debounceTimeout={300}
        onChange={(event) => setValue(event.target.value)}
      />
      <p>Value: {value}</p>
    </div>
  );
}

export default App;

Other packages similar to react-debounce-input

Keywords

FAQs

Package last updated on 06 Jun 2022

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