Skip to content

React 18 Bug: react-dom/server "Detected multiple renderers..." if preceeded by react-test-renderer #22796

Closed
@eps1lon

Description

@eps1lon

React version: 18.0.0-beta-149b420f6-20211119

Steps To Reproduce

  1. render a context with react-test-renderer (wrapped in act)
  2. render the same context with react-dom/server

Link to code example: https://codesandbox.io/s/react-18-react-test-renderer-react-dom-server-forked-lbs7j?file=/package.json:189-219

const Context = React.createContext(null);

function Component({ renderer }) {
  return (
    <Context.Provider value={renderer}>
      <div />
    </Context.Provider>
  );
}

let testRendererRoot;
ReactTestRenderer.act(() => {
  testRendererRoot = ReactTestRenderer.create(
    <Component renderer="react-test-renderer" />
  );
});
ReactTestRenderer.act(() => {
  testRendererRoot.unmount();
});

ReactDOMServer.renderToString(<Component renderer="react-dom/server" />);

The current behavior

renderToString results in the console error "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."

The expected behavior

No error like in React 17 (https://codesandbox.io/s/react-17-react-test-renderer-react-dom-server-yr8gx).
Considering all renders are wrapped in their corresponding act I don't expect that I'm concurrently rendering.

I tried to understand when we reset the rendererSigil (responsible for checking if we "concurrently rendering") is reset and it seems like we never reset it but only initialize it when creating the context (createContext)
So it either seems like multiple renderers in the same module are not supported anymore or the reset is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    React 18Bug reports, questions, and general feedback about React 18Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugType: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions