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.
this._currentlyRenderingComponent !== null,
      'Hooks can only be called inside the body of a function component. ' +
        '(https://fb.me/react-invalid-hook-call)',
    );
  }
  _createDispatcher(): DispatcherType {
    const useReducer = <S, I, A>(
      reducer: (S, A) => S,
      initialArg: I,
      init?: I => S,
    ): [S, Dispatch<A>] => {
      this._validateCurrentlyRenderingComponent();
      this._createWorkInProgressHook();
      const workInProgressHook: Hook = (this._workInProgressHook: any);
      if (this._isReRender) {
        
        
        const queue: UpdateQueue<A> = (workInProgressHook.queue: any);
        const dispatch: Dispatch<A> = (queue.dispatch: any);
        if (this._renderPhaseUpdates !== null) {
          
          const firstRenderPhaseUpdate = this._renderPhaseUpdates.get(queue);
          if (firstRenderPhaseUpdate !== undefined) {
            (this._renderPhaseUpdates: any).delete(queue);
            let newState = workInProgressHook.memoizedState;
            let update = firstRenderPhaseUpdate;
            do {