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.
}
        }
        if (elementType.contextTypes) {
          currentlyValidatingElement = element;
          checkPropTypes(
            elementType.contextTypes,
            this._context,
            'context',
            getName(elementType, this._instance),
            getStackAddendum,
          );
          currentlyValidatingElement = null;
        }
        this._mountClassComponent(elementType, element, this._context);
      } else {
        let shouldRender = true;
        if (
          isMemo(element.type) &&
          elementType === this._previousComponentIdentity &&
          previousElement !== null
        ) {
          
          const compare = element.type.compare || shallowEqual;
          if (compare(previousElement.props, element.props)) {
            shouldRender = false;
          }
        }
        if (shouldRender) {
          const prevDispatcher = ReactCurrentDispatcher.current;
          ReactCurrentDispatcher.current = this._dispatcher;