title: React 16.3+ correct way to fire onChange from state change
body: <p>So I have this component:</p>
  
  <pre><code>import React from 'react';
  import PropTypes from 'prop-types';
  import { isEqual } from 'lodash';
  
  class SomeComponent extends React.Component {
    static propTypes = {
      onChange: PropTypes.func,
    };
  
    previousItems = [];
  
    constructor(props) {
      super(props);
      this.state = {
        items: ['some', 'list'],
      };
    }
  
    setState(stateSetter) {
      super.setState(previousState =&gt; {
        const newState = stateSetter(previousState);
  
        if (!isEqual(newState.items, this.previousItems)) {
          this.props.onChange &amp;&amp; this.props.onChange(newState.items);
          this.previousItems = newState.items;
        }
  
        return newState;
      });
    }
  }
  </code></pre>
  
  <p>And what I'm trying to do is listen to change to state and fire <code>onChange</code> when that state changes. I used to do this using <code>componentWillUpdate</code> but I hear that will change in React 17.</p>
  
  <p>What's the correct way to do it now? What I did above feels hacky.</p>
  
  <p>Thanks!</p>