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

Use ReactDOM from window/global scope #526

Closed
harlow opened this issue Oct 19, 2015 · 23 comments
Closed

Use ReactDOM from window/global scope #526

harlow opened this issue Oct 19, 2015 · 23 comments

Comments

@harlow
Copy link

harlow commented Oct 19, 2015

Facebook's install page (https://github.com/facebook/react#installation) recommends including both React and ReactDOM from CDN.

<!-- The core React library -->
<script src="https://fb.me/react-0.14.0.js"></script>
<!-- The ReactDOM Library -->
<script src="https://fb.me/react-dom-0.14.0.js"></script>

By using this style we don't need to vendor ReactDOM directly. Would it make sense to do this:

var ReactDOM = (typeof window !== "undefined" ? window['ReactDOM'] : typeof global !== "undefined" ? global['ReactDOM'] : null);

Here:
https://github.com/JedWatson/react-select/blob/master/dist/react-select.js#L73

Thoughts?

@twe4ked
Copy link

twe4ked commented Oct 23, 2015

👍

@wavejumper
Copy link

Another 👍 - would allow this library to work for other compile to js languages (eg clojurescript)

@TigerC10
Copy link

Count that +1 for 👍 - this killed react-select in my build system since I'm not leveraging browserify or requirejs (yet).

@sobrinho
Copy link

Another 👍, the component is broken on browsers without module loaders.

@bavardage
Copy link

👍

@l4u
Copy link

l4u commented Nov 6, 2015

👍 When react-select is used with Bower and react-rails, it shows Error: Cannot find module 'react-dom'. When we can reuse window.ReactDOM, it works.

@dbkaplun
Copy link

dbkaplun commented Nov 7, 2015

+1

@twe4ked
Copy link

twe4ked commented Nov 8, 2015

@JedWatson is there a reason not to do this?

@twe4ked
Copy link

twe4ked commented Nov 8, 2015

Thanks, I'll give this a go now!

@JedWatson
Copy link
Owner

@twe4ked had to figure out the right way to do it without interfering with the other build processes and target environments. Done now, and I've added an updated usage example in examples/src/standalone.html

@twe4ked
Copy link

twe4ked commented Nov 8, 2015

Actually I'm using bower so I'm not sure this will fix it for me. I'll have a look now.

Edit: Thanks for the explanation :)

@JedWatson
Copy link
Owner

I'll have to publish a new version before it works from bower, but you can test it by downloading the repo directly from npm and dropping the dist folder into your project (this is effectively what bower does anyway)

@sobrinho
Copy link

sobrinho commented Nov 9, 2015

Thanks! \o/

@mockdeep
Copy link

Has this been released to bower yet? We just tried to plug it in alongside react-rails and got the same error as @l4u above.

@l4u
Copy link

l4u commented Nov 19, 2015

@mockdeep Use the build at or after b2afb88

@mockdeep
Copy link

@l4u are you including it in your project assets or using rails-assets? We actually just ended up setting up browserify-rails and will probably move to using the npm package.

@l4u
Copy link

l4u commented Nov 19, 2015

@mockdeep we have to wait for a new release v1.0.0-beta6 before we can use it with rails-assets (bower). Alternatively you can get the dist/react-select.js at b2afb88

@bondarevpavel
Copy link

Thanks! Using master branch for fixing this.

@atroche
Copy link

atroche commented Nov 24, 2015

Thanks! I'm on master too, and it's working well. Any ETA on when anyone can cut a new release? This PR is depending on it: cljsjs/packages#273

But no rush =)

@twe4ked
Copy link

twe4ked commented Nov 24, 2015

I've got a feeling this is waiting on #568.

@atroche
Copy link

atroche commented Nov 24, 2015

@JedWatson any chance of a quick beta release, just so we can use this fix on a release?

@l4u
Copy link

l4u commented Dec 3, 2015

@moggyboy The patch has been applied to v1.0.0-beta6 only. If you use 0.9.x, you've to edit that ReactDOM line. Which version are you using?

@michaelwebb76
Copy link

@l4u Thank you - I noticed you'd already answered above and so I deleted my comment.

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