Skip to content

polosson/use-debounced-effect

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useDebouncedEffect react hook

Install it with yarn:

yarn add use-debounced-effect --save

Or with npm:

npm i use-debounced-effect --save

#Example

import React, { useState } from 'react';
import useDebouncedEffect  from 'use-debounced-effect';

export default function Input() {
  const [term, setTerm] = useState('');

  useDebouncedEffect(()=>{
    console.log(term); // debounced 1sec
    // call search api ...
  }, 1000 ,[term]);
  
  return (
    <input onChange={(e)=>setTerm(e.target.value)} />
  );
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%