npm.io
1.0.1 • Published 6 years ago

@nicer-toolbox/use-debounce

Licence
MIT
Version
1.0.1
Deps
0
Size
6 kB
Vulns
0
Weekly
0

Nicer Toolbox

Use Debounce

Debounce a react useState value

NPM JavaScript Style Guide

Usage

function App() {
  const [count, setCount] = useState(0)
  const delayedValue = useDebounce(value, 3000)

  return (
    <div className='App'>
      <h1>Counter</h1>
      <p>Current count: {value}</p>
      <p>Debounce count: {delayedValue}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  )
}

Keywords