Skip to content

hailtrace/use-debounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple hook that debounces with options.

import React, { useState, useCallback } from 'react';
import useDebounce from '@hailtrace/use-debounce';

function MyComponent() {
  const [ text, setText ] = useState();
  
  const handleSetText = useDebounce(
    useCallback((event) => {
      setText(event.target.value);
    }),
    1000,
    { leading: true, trailing: true },
  );

  return <input onChange={event => handleSetText(event.target.value)} placeholder="Text Input" />
}

About

A react hook for debounce.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published