All Projects → podefr → React Debounce Render

podefr / React Debounce Render

Licence: other
A React higher order component to debounce the rendering of your React components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Debounce Render

Fast React Render
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 102 (-32%)
Mutual labels:  performance, render
Why Did You Render
why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.)
Stars: ✭ 7,695 (+5030%)
Mutual labels:  performance, render
React Virtual List
Super simple virtualized list React component
Stars: ✭ 597 (+298%)
Mutual labels:  performance, render
Fast React Server
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 139 (-7.33%)
Mutual labels:  performance, render
Is Esm
🌳 CLI tool which checks if a package is distributed in ECMAScript module format. Helps you reason if the package is tree-shakable.
Stars: ✭ 147 (-2%)
Mutual labels:  performance
React Native Wormhole
⚛️ 🌌 Inter-dimensional Portals for React Native. 👽 🖖
Stars: ✭ 133 (-11.33%)
Mutual labels:  render
Lithoxyl
Application instrumentation and logging, with a geological bent.
Stars: ✭ 141 (-6%)
Mutual labels:  performance
Forge
High Performance Visualization
Stars: ✭ 140 (-6.67%)
Mutual labels:  performance
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (+1112.67%)
Mutual labels:  performance
Deli
Stars: ✭ 148 (-1.33%)
Mutual labels:  performance
Terminalizer
🦄 Record your terminal and generate animated gif images or share a web player
Stars: ✭ 12,165 (+8010%)
Mutual labels:  render
React Native Lazy Index
RAM bundle friendly, bundle-time generated `index.js`
Stars: ✭ 143 (-4.67%)
Mutual labels:  performance
React Live Chat Loader
Implement a live chat beacon in your React application without performance regressions.
Stars: ✭ 145 (-3.33%)
Mutual labels:  performance
Async
Easily run code asynchronously
Stars: ✭ 1,983 (+1222%)
Mutual labels:  performance
Easyengine
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt
Stars: ✭ 1,881 (+1154%)
Mutual labels:  performance
Rust.js
Run your JavaScript apps backed by Rust
Stars: ✭ 141 (-6%)
Mutual labels:  performance
Monkeytest
monkey android test
Stars: ✭ 145 (-3.33%)
Mutual labels:  performance
Web Vitals Extension
A Chrome extension to measure essential metrics for a healthy site
Stars: ✭ 1,943 (+1195.33%)
Mutual labels:  performance
Georaptor
Python Geohash Compression Tool
Stars: ✭ 143 (-4.67%)
Mutual labels:  performance
Nemetric
前端性能指标的监控,采集以及上报。用于测量第一个dom生成的时间(FP/FCP/LCP)、用户最早可操作时间(fid|tti)和组件的生命周期性能,,网络状况以及资源大小等等。向监控后台报告实际用户测量值。
Stars: ✭ 145 (-3.33%)
Mutual labels:  performance

npm Actively Maintained

react-debounce-render

react-debounce-render is a Higher Order Component that wraps your react components and debounces their rendering.

This method can be used to prevent extra renders when a react component rapidly receives new props by delaying the triggering of the render until updates become less frequent. Doing so will improve the overall rendering time of the application, thus improve the user experience.

It uses lodash debounce under the hood, which means that it can be configured just like lodash debounce.

Rationale:

Sometimes it's difficult, impractical or impossible to batch props updates before they're passed down to a react component, resulting in a react component being rendered too often while only the last props update might have been useful and should have triggered a rendering of the component. In these cases, debouncing the rendering of a react component may be the only solution to improve performance.

react-debounce-render is a react component that will wrap any of your react components, persist the last props update that was received while discarding the previous ones, and only rendering the wrapped component when no new updates has been received in the last few milliseconds by default. Since the debounce function used under the hood is lodash's debounce, you may also pass in a few options such as the number of milliseconds to delay the render by, a maximum delay, or whether to call render on a leading or trailing edge of the timeout.

Usage:

Default usage:

import debounceRender from 'react-debounce-render';

const debouncedMyReactComponent = debounceRender(MyReactComponent);

// do whatever you want with the debounced component such as connecting to a redux store:
connect(state => {
    myProp: (state) => getProp(state)
})(debouncedMyReactComponent);

With options:

See lodash debounce for all options. Debounce render takes its parameters similarily to lodash debounce:

To trigger the debounce on the leader edge:

import debounceRender from 'react-debounce-render';

const debouncedMyReactComponent = debounceRender(MyReactComponent, 100, { leading: false });

Or to ensure that at least one refresh happens every second:

import debounceRender from 'react-debounce-render';

const debouncedMyReactComponent = debounceRender(MyReactComponent, 100, { maxWait: 1000 });

Compose with other HOCs:

Use debounce instead of debounceRender to compose with other HOCs and some compose utility function. maximizing composability convention

import { debounce } from 'react-debounce-render';
import { withStyles } from '@material-ui/core/styles';
import { compose } from 'ramda';

// ...

export default compose(
  withStyles(styles),
  debounce(200, {maxWait: 400})
)(MyReactComponent);

Changelog

7.0.0 - AUG 22 2020

6.1.0 - JUNE 23 2020

  • Fix import of lodash.debounce. See PR #20. Thanks ReinAkane for the contribution!

6.0.0 - FEB 04 2020

  • Add support for hoisting non-react statics. See PR #16 for more details. Thanks Thomas0c for the contribution!
  • Update e2e tests to use the most recent React version
  • Drop supports for React <= 15

5.0.0 - OCT 04 2018

There is no breaking change in this version despite the major version change, this is only to highlight the fact that most of the internal implementation has changed since PR #12.

  • Removes unused lodash dependency since we're using lodash/debounce. Thanks @yched for raising the issue!
  • Using @yched cleaner implementation which doesn't use the deprecated lifecycle methods nor trigger any warning. See Issue #11.

4.0.3 - JULY 19 2018

  • Revert 4.0.2 change and use latest lodash version again, though importing lodash/debounce directly. Thanks @faizrr for raising the issue!

4.0.2 - JULY 6 2018

  • Use lodash.debounce instead of lodash to reduce built package size. Thanks @faizrr for raising the issue!

4.0.1 - APRIL 3 2018

  • Ensure that debounce is properly canceled when the component is unmounted which removes the "Warning: Can only update a mounted or mounting component." warning. Resolves Issue #5. Thanks @mjhm for the fix.

4.0.0 - NOVEMBER 20 2017

  • Move react to the peerDependencies in package.json and accept major versions greater than 15. Resolves Issue #4. Thanks @TheSharpieOne for raising the issue.

3.0.0 - AUGUST 16 2017

  • import debounceRender from 'react-debounce-render' should now consistently work. See Issue #2. Thanks @CameronAckermanSEL for raising the issue. As a result, using a destructuring assignment in the import statement (import { debounceRender } from 'react-debounce-render'') shouldn't accidentally work anymore which is a potential breaking change.

2.0.0 - JULY 31 2017

  • Module isn't built as standalone before being published to npm, resulting in a cleaner and lighter package. Also removes non lib related files from the package. See PR #1. Thanks @wbazant for the contribution.

1.0.0 - JUNE 25 2017

  • debounces a React component's render method()
  • includes e2e tests and documentation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].