-
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
Multiple React instances per DOM (when using AMD for example) #3252
Comments
If I may be so bold, I see two ways forward. Either each React knows about other instances of React through something global (it's operating over the entire DOM after all) or each React instance creates its own random root key in |
Is this #2402? |
I did not see that one. It is similar, but where they just want a warning (that they can presumably act upon by removing one of the Reacts they mistakenly loaded), there are scenarios where multiple |
I don't understand. What is the use case for this? |
The cases I've seen are usually around addons or 3rd-party widgets/scripts. |
Mine is UI composition via AMD, but it could be something like two separate CommonJS bundles on a page (possibly - I don't use CommonJS), or widgets. |
The other issue with this is you can't reliably use the dependency injection mechanism, e.g. to change the batching strategy, while using components from multiple modules where each has it's own instance of React as a dependency. Even if they are the same version of React. (originally posted here, sorry for the duplicate comment: #2402 (comment)) |
+1 |
+1 |
I'm interested in using React from inside Chrome extensions to add stuff to pages (that may or may not be using React themselves). Chrome extensions share the DOM but don't share the javascript context with the page, so I guess this falls under "multiple React instances operating over the same DOM (but not component tree)". |
+1 |
@charypar said: "The other issue with this is you can't reliably use the dependency injection mechanism, e.g. to change the batching strategy, while using components from multiple modules where each has it's own instance of React as a dependency. Even if they are the same version of React." This. |
+1 Seeing similar issue in many places with the error being shown from #2402, I have to write in AMD since our company uses Esri's JavaScript API, which heavily relies on Dojo. I have one module which creates a component and returns the result of React.createClass. Somewhere else in the app we will call React.render(<MyComponent />, someNode); and it throws the multiple instances error. I can get around this by returning something like
Also seeing it occasionally in jasmine-node when calling TestUtils.renderIntoDocument Note: I noticed this started when upgrading to React 0.13.1 |
+1 noticed this in nodejs, calling a renderToStaticMarkup from one package on react components from another package. |
+1 |
1 similar comment
+1 |
+1 |
Yea, closing. This is the same as other issues mentioned. |
@zpao what issue is this now tracked under please? |
When using AMD, a component might use React as a dependency. This poses a problem when another instance of React has already manipulated the DOM. The wrong events get fired, or ID collisions occur (Invariant Violation: ReactMount: Two valid but unequal nodes with the same
data-reactid
: .0).jsbin here: http://jsbin.com/riqotavoxa/11/edit?js,output
SO here for internet points: http://stackoverflow.com/q/28685857/614523
Google Group post here: https://groups.google.com/forum/#!topic/reactjs/RRDUaF19CM0
The text was updated successfully, but these errors were encountered: