@hailtrace/use-debounce
v1.0.0
Published
A react debounce hook with options.
Downloads
1
Readme
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" />
}