title: getDerivedStateFromProps called everytime when local state change
body: <p>Currently I am setting <code>ownUpdate: true</code> state when we are changing state from same component and check it in getDerivedStateFromProps accordingly. Below is the code I am using in my component. Can anyone suggest better way of doing this. Thanks in advance. </p>
  
  <pre><code>constructor(props) {
      super(props);
      this.state = {
          expanded: props.expanded,
          ownUpdate: false
      }
  }
  
  static getDerivedStateFromProps(props, state) {
      if (state.ownUpdate) {
          return {
              expanded: state.expanded,
              ownUpdate: false
          };
      } else if (props.expanded !== state.expanded) {
          return {
              expanded: props.expanded
          };
      }
      return null;
  }
  
  toggle() {
      this.props. onAfterPress(this.state.expanded, this.props.index);
      this.setState({
          expanded: !this.state.expanded,
          ownUpdate: true
      })
  }
  </code></pre>