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 data attributes conflicting with existing react components #3

Closed
nelix opened this issue Sep 17, 2014 · 9 comments
Closed

React data attributes conflicting with existing react components #3

nelix opened this issue Sep 17, 2014 · 9 comments

Comments

@nelix
Copy link
Contributor

nelix commented Sep 17, 2014

I am using react-frame-component from a chrome extension content script, if I load it into a page that is already using react I get this error:
Uncaught Error: Invariant Violation: ReactMount: Two valid but unequal nodes with the same data-reactid: .0.0
is there a way to work around this?

@nelix
Copy link
Contributor Author

nelix commented Dec 9, 2014

In case anyone else ever comes across this, the way I solved this issues is with this hack:

require('react/lib/DOMProperty').ID_ATTRIBUTE_NAME = 'data-myproductid';

If you do this before requiring react and you use a module loader like webpack (I assume browserify is much the same?) this should work.

You can also just search and replace your react lib or app bundle.

@nelix nelix closed this as completed Dec 9, 2014
@ryanseddon ryanseddon reopened this Dec 9, 2014
@ryanseddon
Copy link
Owner

@nelix apologies for missing this I'm not sure how I did! I've asked some react people to comment on this and see if there is a better solution.

@nelix
Copy link
Contributor Author

nelix commented Dec 9, 2014

I got the solution from the react irc channel, from @syranide

@ryanseddon
Copy link
Owner

Ah ok I'll leave this open and see if anyone has any other solutions. I'll close it off tomorrow if not.

@ryanseddon
Copy link
Owner

This seems to be related facebook/react#1939

@nelix
Copy link
Contributor Author

nelix commented Jan 8, 2015

should we add comments about the id name spacing to the readme?

@KelWill
Copy link

KelWill commented Jun 29, 2015

nelix thanks for the hack -- worked perfectly!

@ryanseddon -- any chance we could add that line of code to react-frame-component? It seems like the default should be for it to have a different data-reactid than the normal one so that anything in an iframe doesn't conflict with a regular react project.

@ryanseddon
Copy link
Owner

I'm not sure that should be part of this library, it should definitely be added to the readme. Wanna do a PR?

@ryanseddon
Copy link
Owner

This is fixed via #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants