Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eps1lon opened this issue Nov 20, 2021 · 2 comments · Fixed by #22797
Labels
React 18 Bug reports, questions, and general feedback about React 18 Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@eps1lon
Copy link
Collaborator

eps1lon commented Nov 20, 2021

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.

@eps1lon eps1lon added Type: Bug Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug React 18 Bug reports, questions, and general feedback about React 18 labels Nov 20, 2021
jerrydev0927 added a commit to jerrydev0927/react that referenced this issue Jan 5, 2024
@iammerrick
Copy link
Contributor

Has this been released? I can't tell if its in the current 18.2? 18.3? 19@beta?

@eps1lon
Copy link
Collaborator Author

eps1lon commented Apr 30, 2024

Fixed in 19@beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React 18 Bug reports, questions, and general feedback about React 18 Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants