Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Detect duplicate React and show a different message #700

Closed
gaearon opened this issue May 8, 2017 · 6 comments
Closed

Detect duplicate React and show a different message #700

gaearon opened this issue May 8, 2017 · 6 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented May 8, 2017

It would be cool if, in addition to DEV mode detection, we could detect when there are two instances of ReactDOM on the page.

This issue mentions how we could detect it: #692.

One thing to keep in mind is it's valid to have two different renderers (e.g. ReactDOM + ReactART), but not two instances of one renderer. Not sure if there's an easy way to tell those cases apart, but we can make changes to React if necessary to support that.

@chisler
Copy link

chisler commented May 9, 2017

I'd be happy to try to add that detection!

@gaearon
Copy link
Contributor Author

gaearon commented May 9, 2017

👍

@chisler
Copy link

chisler commented May 10, 2017

Hi! This is my first open source contribution. I log current status of the issue.

  1. Detecting several renderers is simple.
  2. Guessing renderer type by the object is not, at least for now.

However, I found only 1 custom renderer that explicitly fires .inject => may interfere dumb checking hook._renderers.length > 1.

Duplicate React among A-C sites-using-react, found with extension
Renderes I’ve studied

I've studied popular renderers (from list1 & list2) on the matter of self-injection.

Renderers that inject themselves correctly:

These do not inject themselves:

These ones fire injection but are not hooked in browser:

P.S. I don’t see the generic solution without modifying react-dom injection yet. Modification of current react-dom version will not provide backward compatibility, so we won't be able to detect latest ReactDOM + old one, only two new ones. This is not a case yet. I hope it's ok to think about it for a few more days.

@ngyikp
Copy link
Contributor

ngyikp commented Sep 24, 2017

Additional problem: It's impossible to tell whether a duplicated React is a mistake by the site developer or they are using some third-party libraries that also uses React. (facebook/react#10768)

Example: https://www.kenhub.com/en/atlas/acromion (third-party library: https://djtflbt20bdde.cloudfront.net )

Perhaps in future version that can show a table of React renderers on the page and the minification status for each?

@chisler
Copy link

chisler commented Sep 24, 2017

Hi! Thank you for the comment.

I pointed that out in code: // Currently we overwrite buildType with each injected renderer's type.

The issue with overwriting is applicable to any renderer inspection: it only depends on the order they inject. The table will allow to report unminified and duplicated React as well.

I wanted to suggest the table too, though I felt like it's a next step, because it's a change in the way we report, not duplication problem.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 19, 2019

React DevTools has been rewritten and recently launched a new version 4 UI. The source code for this rewrite was done in a separate repository and now lives in the main React repo (github.com/facebook/react).

Because version 4 was a total rewrite, and all issues in this repository are related to the old version 3 of the extension, I am closing all issues in this repository. If you can still reproduce this issue, or believe this feature request is still relevant, please open a new issue in the React repo: https://github.com/facebook/react/issues/new?labels=Component:%20Developer%20Tools

@bvaughn bvaughn closed this as completed Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants