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.
return prevState[0];
          }
        }
      }
      const nextValue = nextCreate();
      (this._workInProgressHook: any).memoizedState = [nextValue, nextDeps];
      return nextValue;
    };
    const useRef = <T>(initialValue: T): {current: T} => {
      this._validateCurrentlyRenderingComponent();
      this._createWorkInProgressHook();