Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useDebounce

yarn add use-debounce
// or
npm i use-debounce --save

// Usage: 
import React, { useState } from 'react';
import { useDebounce } from 'use-debounce';

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

  return (
    <div>
      <input
        defaultValue={'Hello'}
        onChange={(e) => {
          setText(e.target.value);
        }}
      />
      <p>Actual value: {text}</p>
      <p>Debounce value: {value}</p>
    </div>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: apollo uselazyquery oncompleted 
Javascript :: how to navigate to another page with settimeout reactjs 
Javascript :: react extends component Increment data 
Javascript :: document.getelementsbyclassname equivalent in jquery 
Javascript :: header react native 
Javascript :: js check if string contains character 
Javascript :: window.open 
Javascript :: table to pdf javascript 
Javascript :: examples of Conditional Operator js 
Javascript :: how to convert string to toggle case in javascript 
Javascript :: create a panda component react 
Javascript :: node js rate limiter fastify 
Javascript :: react spinner 
Javascript :: js check if array contains value 
Javascript :: React ES6 Arrow Functions 
Javascript :: jsx else if statement 
Javascript :: how to check if expo app is running on the web 
Javascript :: install svelte router 
Javascript :: js comment 
Javascript :: input in html table 
Javascript :: postfix date javascript 
Javascript :: inject html via template tags js 
Javascript :: javascript add item by index 
Javascript :: whatare portals in react 
Javascript :: shopify get list of all products ajax api 
Javascript :: js display 
Javascript :: file-loader support json file 
Javascript :: Expo Location get getCurrentPositionAsync not returning anything 
Javascript :: programmatically create a custom cron job drupal 7 
Javascript :: Using the Sanity client without specifying an API version is deprecated 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =