Throttle the number of times a component receives new props not to call render()
too many times.
It may enhance the performance under the following conditions.
- The component receives new props frequently.
- The component has a huge or slow
render()
.
npm i --save react-throttle-props
import throttle from 'react-throttle-props'
const ThrottledComponent = throttle(VeryBigRenderComponent, 50)
-
component
The source React component -
wait
The number of milliseconds to throttle -
wrappedComponent
The throttled React component
MIT