In reference to React: Optimize Re-Renders with shouldComponentUpdate
https://www.freecodecamp.org/learn/front-end-libraries/react/optimize-re-renders-with-shouldcomponentupdate
For “fun” I changed
if (nextProps.value % 2 == 0) {
return true;
to
if (this.props.value % 2 == 0) {
return true;
and sure enough everything is off by one. It returns odd numbers. But I don’t see why.
When the button is clicked isn’t addValue executed right away? Therefore when OnlyEvens runs isn’t this.props.value is already the next value?