ex-component-update

1.0.2 • Public • Published

ex-component-update

sh: npm install ex-component-update

A convenient alternative to shouldComponentUpdate. Freezes only the component itself, without affecting children. It is enough to return a list of values that affect the render.

import modelScreen from 'src/models/modelScreen.js'

class MyCard extends React.Component {
    constructor() {
        exComponentUpdate(this, false|true|options);
        ..
    };

    exComponentUpdate(nextProps, nextState) {
        var data = nextProps.data || false;
        return [
            modelScreen.width <= 500,
            modelScreen.width <= 980,
            data.name,
            data.email,
            data.phone,
            ..
        ];
    };

    render() {
        return ...
    };
};

Package Sidebar

Install

npm i ex-component-update

Weekly Downloads

57

Version

1.0.2

License

none

Unpacked Size

8.26 kB

Total Files

4

Last publish

Collaborators

  • vflash