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.
const randomNumber = React.useMemo(() => {
        return {number: Math.random()};
      }, []);
      return (
        <div>
          <p>The random number is: {randomNumber.number}</p>
        </div>
      );
    }
    const shallowRenderer = createRenderer();
    let firstResult = shallowRenderer.render(<SomeComponent />);
    let secondResult = shallowRenderer.render(<SomeComponent />);
    expect(firstResult).toEqual(secondResult);
  });
  it('should work with useContext', () => {
    const SomeContext = React.createContext('default');
    function SomeComponent() {