1.0.4 • Published 6 years ago

react-buffer-component v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Build Status

React Buffered Component

This package allows you to make your component update buffered on a certain condition.

Installation

You can run this package to use the package

npm install --save react-buffered-component

How to use the package

You can just extends this base class for your component.

import BufferedComponent extends 'react-buffered-component';

class HelloComponent extends BufferedComponent {
    // set the time you would like to wait in milliseconds
    // default value is 0;
    timeBuffer = 1000;
    // the time when your component receive an update, either props update or internal state update
    cycleBuffer = 10;

    // if you define both of them above, the BufferedComponent will determine which one
    // will be quickest to update the component.

    render() {
        // do your thing here
    }
}

The BufferedComponent use shouldComponentUpdate cycle to buffer the update. if you want to override it, make sure you call something like this

class HelloComponent extends BufferedComponent {
....
    shouldComponentUpdate(props, state){
        ...
        const shouldUpdate = super();
        // do your own logic here.
        ...
        // then do return a boolean value to determine if it would update the component or not
    }
....
}

Contribution

I love feedback so you can put your feedback to Issues or make a pull request to this package. I love to get any comments regarding my work. Or you can click donate button below. Happy Coding.

npm.io