-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Why does React warn about multiple renderers using the same context provider? #19519
Comments
React only supports two concurrent renderers at most– one "primary" and one "secondary", e.g. React DOM (primary) and React ART (secondary) or React Native (primary) and Fabric (secondary). This is partially a practical constraint (in that it covers 99% of use cases) and partially an intentional trade off in that certain APIs (like Context or For example, rather than using a (slower) react/packages/react-reconciler/src/ReactFiberNewContext.new.js Lines 78 to 111 in 93a0c28
Same for the react/packages/react-reconciler/src/ReactMutableSource.new.js Lines 30 to 62 in 93a0c28
This warning suggests that two renderers of the same type (presumably two primary renderers) are both using a context at the same time (concurrently). This might happen to work okay in some cases (e.g. if only the global/default context value is being used) but it may also break depending on how each renderer is using the context. Hope this helps answer your question! tl;dr is that the warning is valid and important. |
Thank you for such a detailed answer! now I understand. Both of react-pixi and react-babylonjs have a custom renderer, plus the original |
I am currently developing a web app that uses both react-pixi and react-babylonjs. Both of these libraries use
react-reconciler
and have a custom renderer. I also use redux in my project, so they share the same Context in the two libraries.It displays a warning on Console after every redux state updating, but everything works well, both renderers can trigger an update.
I want to know if there is any risk in doing this, or is this just a false warning?
React version: 16.13.1
Steps To Reproduce
Link to code example: https://codesandbox.io/s/multiple-reconciler-using-same-context-v8kq1?file=/src/App.js
The current behavior
It will throw a warning message after every state updating:
But everything works well, both renderers can trigger an update.
The expected behavior
Don't show any warning.
The text was updated successfully, but these errors were encountered: