Calling `ReactDOMServer.renderToStaticMarkup(elementWithPortal);` gets stuck in a loop while trying to do a static render.

Current behavior:
The behavior can be seen here: https://codepen.io/anon/pen/BmqWOM  by un-commenting line 58 (warning: this will make your tab freeze)

Expected behavior:
It should return with results or throw some kind of error if the input is not valid

ReactDOM.unmountComponentAtNode(element);
      expect(element.innerHTML).toEqual('');
      ReactDOM.render(<TestComponent name="x" />, element);
      expect(mountCount).toEqual(2);
      expect(element.innerHTML).not.toEqual(lastMarkup);
      
      
      
      
      ReactDOM.unmountComponentAtNode(element);
      expect(element.innerHTML).toEqual('');
      lastMarkup = ReactDOMServer.renderToString(<TestComponent name="x" />);
      element.innerHTML = lastMarkup;
      var instance = ReactDOM.render(<TestComponent name="x" />, element);
      expect(mountCount).toEqual(3);
      if (__DEV__) {
        expect(console.warn.calls.count()).toBe(1);
        expect(console.warn.calls.argsFor(0)[0]).toContain(
          'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' +
            'will stop working in React v17. Replace the ReactDOM.render() call ' +
            'with ReactDOM.hydrate() if you want React to attach to the server HTML.',
        );
        console.warn.calls.reset();
      }
      expect(element.innerHTML).toBe(lastMarkup);
      
      expect(numClicks).toEqual(0);
      ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(instance.refs.span));
      expect(numClicks).toEqual(1);