Skip to content

vflash/ex-component-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 ...
    };
};

About

react.js render - only where it should be

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published