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

componentWillMount() {
        this.setState({text: 'hello'});
        setTimeout(() => {
          this.setState({text: 'error'});
        });
      }
      render() {
        return <div onClick={() => {}}>{this.state.text}</div>;
      }
    }
    spyOnDev(console, 'error');
    ReactDOMServer.renderToString(<Foo />);
    jest.runOnlyPendingTimers();
    if (__DEV__) {
      expect(console.error.calls.count()).toBe(1);
      expect(console.error.calls.mostRecent().args[0]).toBe(
        'Warning: setState(...): Can only update a mounting component.' +
          ' This usually means you called setState() outside componentWillMount() on the server.' +
          ' This is a no-op.\n\nPlease check the code for the Foo component.',
      );
    }
    var markup = ReactDOMServer.renderToStaticMarkup(<Foo />);
    expect(markup).toBe('<div>hello</div>');
    jest.runOnlyPendingTimers();
    if (__DEV__) {
      expect(console.error.calls.count()).toBe(1);
    }
  });
  it('warns with a no-op when an async forceUpdate is triggered', () => {
    class Baz extends React.Component {