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

0.0.2 • Public • Published

A custom hook for react: useDebounce

Demo (Codepen)

https://codepen.io/ferdotnet/pen/MWXXzbg

Install

yarn add @ferdotnet/use-debounce

How to use it?

const App = () => {
    const [query, setQuery] = useState('');
    const qDebounced = useDebounce(query);
    
    const handleChange = (el) => {
        setQuery(el.target.value);
    };
    
    return (
        <div className="wrapper">
            <input type="text" placeholder="Write something here.." onChange={handleChange} />
            <span>{qDebounced || '👀'}</span>
        </div>
    );
});

Readme

Keywords

none

Package Sidebar

Install

npm i @ferdotnet/use-debounce

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

2.52 kB

Total Files

6

Last publish

Collaborators

  • ferdotnet