Basically, everything need to be done in shouldComponentUpdate() method.
import React, {Component} from 'react';
class Item extends Component {
shouldComponentUpdate(nextProps, nextState) {
// always re-render component
return true;
}
render() {
return (
<div/>
);
}
}
If we don’t mind compare all properties, we can use pre-defined implementation.
import React, {PureComponent} from 'react';
class Item extends PureComponent {
render() {
return (
<div/>
);
}
}
Also we can create relevant enhancer much easier with recompose:
https://bl.ocks.org/mistakster/2d97a72814680d5069df214225c96a5d
It works only in Chrome and Firefox. See console for re-render updates.