Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include ReactDOM with bower

I'm using brunch and so I use bower instead of npm for package dependencies.

I read that React.render(<somReactElement/>, document.getElementById('foobar');); is deprecated and we have to use ReactDOM.render(...);

On NPM you can install it easy as read there : https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html but on bower, Facebook say that react-dom is included in the react lib.

Indeed I find the source lib in package bower_components/react/react-dom.js (there is a minified version too) but I have no idead how to use it.

  • If I install it with bower install --save react-dom I have an other package not related : https://github.com/EtienneLem/react-dom/ .
  • I tried global ReactDOM as read in the lib source code :

    [...]
        if (typeof window !== "undefined") {
          g = window;
        } else if (typeof global !== "undefined") {
          g = global;
        } else if (typeof self !== "undefined") {
          g = self;
        } else {
          // works providing we're not in "use strict";
          // needed for Java 8 Nashorn
          // see https://github.com/facebook/react/issues/3037
          g = this;
        }
        g.ReactDOM = f(g.React);
    [...]
    

But it don't works.

  • I check React.DOM but it not corresponding to the library.

Any idea how to include library without adding the js file in the project (for me a very bad solution because we are not using our package manager anymore for it).

like image 907
Cyril ALFARO Avatar asked Jun 14 '26 23:06

Cyril ALFARO


1 Answers

Ok I find the issue after trying A LOT of things...

I use react-router at last version (0.13.x) and react-bootstrap at last too (version 0.27.x). But react-bootstrap 0.27 depends on react 0.14.x... and this version of react missmatch with the react-router...

Three hours lost on Javascript eco-system...

like image 97
Cyril ALFARO Avatar answered Jun 17 '26 13:06

Cyril ALFARO