function observer(componentClass) {
  if (
    typeof componentClass === 'function' &&
    (!componentClass.prototype || !componentClass.prototype.render) &&
    !componentClass.isReactClass &&
    // eslint-disable-next-line no-prototype-builtins
    !React.Component.isPrototypeOf(componentClass)
  ) {
    class ObserverComponent extends React.Component {
      render() {
        return componentClass.call(this, this.props, this.context)
      }
    }
    ObserverComponent.displayName =
      componentClass.displayName || componentClass.name
    ObserverComponent.contextTypes = componentClass.contextTypes
    ObserverComponent.propTypes = componentClass.propTypes
    ObserverComponent.defaultProps = componentClass.defaultProps
    return observer(ObserverComponent)
  }

  if (!componentClass) {
    throw new Error("Please pass a valid component to 'observer'")
  }

  const target = componentClass.prototype || componentClass
  mixinLifecycleEvents(target)
  return componentClass
}
Reference to mobx https://github.com/mobxjs/mobx-react-vue/blob/master/src/observer.js