@hailtrace/use-debounce
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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" />
}

Readme

Keywords

none

Package Sidebar

Install

npm i @hailtrace/use-debounce

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.2 kB

Total Files

7

Last publish

Collaborators

  • jhartzell
  • nomadgraphix
  • bailycase99