Provides a function to configure React's shouldComponentUpdate() function in a declarative way
npm install configure-should-component-update



Provides a function to build a customized React's shouldComponentUpdate() function in a declarative way.
``javascript
import React from 'react';
import {configureShouldComponentUpdate} from 'configure-should-component-update';
class Label extends React.Component {
static propTypes = {
text: PropTypes.string,
color: PropTypes.any,
};
render() {
// ...
}
}
configureShouldComponentUpdate(Label, {
props: {
text: (prev, next, { key, props, state, nextProps, nextState }) => a == b,
},
state(prevState, nextState, { props, nextProps }) {
return prevState.pressed === nextState.pressed && !nextProps.disabled;
}
});
`
Here configureShouldComponentUpdate function call will create a function inLabel.prototype.shouldComponentUpdate, which will be shallowly comparingthis.props with nextProps and this.state with nextState, but in addition to it,text
the preconfigured properties like will use the corresponding equality comparers
you provide.
Hence, in our example, if
More documentation is to follow.
Licensed under MIT License.