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.
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @emails react-core
 * @jest-environment node
 */
'use strict';
let createRenderer;
let React;
describe('ReactShallowRenderer with hooks', () => {
  beforeEach(() => {
    jest.resetModules();
    createRenderer = require('react-test-renderer/shallow').createRenderer;
    React = require('react');
  });
  it('should work with useState', () => {
    function SomeComponent({defaultName}) {