Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 973 Bytes

index.en-US.md

File metadata and controls

44 lines (34 loc) · 973 Bytes

useDebounce

A hook-version debounce util function.

Examples

Default usage

import React, { useState } from 'react';
import { useDebounce } from '@vergiss/chooks';

export default () => {
  const [val, setVal] = useState('');
  const onValChange = useDebounce(setVal, 300);

  return (
    <div>
      <input onChange={onValChange} />
      <span>Value: {val}</span>
    </div>
  )
}

API

const debounced = useDebounce(
  callback: (...args: any[]) => any,
  delay: number
)

Params

Property Description Type Default
callback Necessary function -
delay Necessary,delay time number -

Result

Property Description Type
debounced Debounced function Function