title: React 16.4 enables getDerivedStateFromProps to be called from state change. How to cope with that?
body: <p>So 16.4 "fixes" a bug in getDerivedStateFromProps and now it gets fired both on props change and on state change. Obviously this is intended, coming from this post: <a href="https://github.com/facebook/react/issues/12898" rel="noreferrer">https://github.com/facebook/react/issues/12898</a>. However for me, saving previous props in the state is a major overkill, so I am asking if someone has made a procedure in coping with a case like this:</p>
  
  <pre><code>class Componentche extends React.Component {
    state = {
      valuesForInput: {
        input1: ''
      }
    }
    static getDerivedStateFromProps(props, state) {
      if (props.someInitialValuesForInput.input1 !== state.valuesForInput.input1) {
        return {
         valuesForInput: {
           ...state,
           input1: props.someInitialValuesForInput.input1
         }
        }
      }
     return state;
  
     render () {
        &lt;Input value='valuesForInput.input1' onChange='(e) =&gt; setState({valuesForInput: {...this.state, input1: e.target.value }})'
     }
  }
  </code></pre>
  
  <p>So in this above case, I will never ever have change in the input, because getDerivedStateFromProps will execute both on new props received and on the setState trigger, and my condition will never even be false.</p>
  
  <p>So what is the correct way to handle this situation? Do I need to really keep the old props in the state and use them for conditions as well?</p>
  
  <p>I just saw this <a href="https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#anti-pattern-unconditionally-copying-props-to-state" rel="noreferrer">post from React</a> but they do not offer a working alternative. </p>
  
  <p>Thanks for your help!</p>