Listing 4-34: Using shouldComponentUpdate() and shallowCompare()
import React from 'react';
import shallowCompare from 'react-addons-shallow-compare';
class ShallowCompare extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
render() {
return <div>foo</div>;
}
}
export default ShallowCompare;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.