See the issue and the test case with original fix in https://github.com/facebook/react/pull/14802.

We'll need to fix it properly, see https://github.com/facebook/react/pull/14802#issuecomment-463277621.
typeof elementType.getDerivedStateFromProps !== 'function' &&
        typeof this._instance.getSnapshotBeforeUpdate !== 'function'
      ) {
        if (typeof this._instance.componentWillMount === 'function') {
          this._instance.componentWillMount();
        }
        if (typeof this._instance.UNSAFE_componentWillMount === 'function') {
          this._instance.UNSAFE_componentWillMount();
        }
      }
      
      if (beforeState !== this._newState) {
        this._instance.state = this._newState || emptyObject;
      }
    }
    this._rendered = this._instance.render();
    
    
  }
  _updateClassComponent(
    elementType: Function,
    element: ReactElement,
    context: null | Object,
  ) {
    const {props} = element;
    const oldState = this._instance.state || emptyObject;
    const oldProps = this._instance.props;
    if (oldProps !== props) {