useDebouncy
🚦React effect hook for debounce.
Features
- 👌 No dependencies.
- 🏋️♀️ Small. <150 bytes. Size Limit controls the size.
- 📖 Types. Support typescript.
- 🎣 Easy. Like useEffect hook.
Installation
npm install use-debouncy
yarn add use-debouncy
Examples
import React, { useState } from 'react';
import useDebouncy from 'use-debouncy';
const App = () => {
const [value, setValue] = useState('');
useDebouncy(
() => fetchData(value),
400,
[value],
);
return (
<input value={value} onChange={(event) => setValue(event.target.value)} />
);
};