Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@react-hook/throttle
Advanced tools
npm i @react-hook/throttle
import {useThrottle, useThrottleCallback} from '@react-hook/throttle'
const Component = props => {
// at a basic level, used just like useState
const [value, setValue] = useThrottle('initialValue')
}
const useMyCallback = (initialState, wait, leading) => {
// this is the same code useThrottle() uses to throttle setState
const [state, setState] = useState(initialState)
return [state, useThrottleCallback(setState, wait, leading)]
}
useThrottle(initialState: any, fps?: number, leading?: boolean)
Property | Type | Default | Description |
---|---|---|---|
initialState | any | The initial state stored in useState | |
fps | number | 30 | Defines the rate in frames per second with which setState is invoked with new state |
leading | boolean | false | Calls setState on the leading edge (right away). When false , setState will not be called until the next frame is due |
[state, setState]
Variable | Type | Description |
---|---|---|
state | any | The value set by setState or the initialState |
setState | Function | A throttled setState callback |
useThrottleCallback(callback: Function, wait?: number, leading?: boolean)
Property | Type | Default | Description |
---|---|---|---|
callback | Function | This is the callback you want to throttle | |
fps | number | 30 | Defines the rate in frames per second with which setState is invoked with new state |
leading | boolean | false | Calls setState on the leading edge (right away). When false , setState will not be called until the next frame is due |
throttledCallback
Variable | Type | Description |
---|---|---|
throttledCallback | Function | A throttled version of your callback |
MIT
FAQs
A React hook for throttling setState and other callbacks
The npm package @react-hook/throttle receives a total of 176,582 weekly downloads. As such, @react-hook/throttle popularity was classified as popular.
We found that @react-hook/throttle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.