Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 893 Bytes

File metadata and controls

41 lines (29 loc) · 893 Bytes

usethrottle

React hook for to throttle functions

NPM JavaScript Style Guide

Install

npm install --save @slynch13/usethrottle

Usage

import React, { useState, useEffect } from 'react'
import { useThrottle } from 'usethrottle'

const App = () => {
  let [example, setExample] = useState(0)
  const throttled = useThrottle((x) => setExample(x), 1000)
  useEffect(() => {
    throttled(example + 1)
  }, [example])
  return (
    <div>
      {example}
    </div>
  )
}
export default App

License

MIT © slynch13


This hook is created using create-react-hook.