Browserify-rails vs react-rails: Winner both

Browserify-rails vs  react-rails: Winner both

Recently, I have installed browserify-rails and react-rails together in the same Ruby on Rails project. This give the best of both worlds since I can still use the react_component helper provided by react-rails but use npm to manage my versions of different React.js components. However, if you install react-rails, make sure you do not run any of the generators. If you are working on an existing codebase, you will probably end up using a hybrid system with some Javascript packages being managed by npm and others imported through Rubygems via sprocket. It is important to make sure that you use only one version of JQuery.

For example, the following code will break:

// application.js
//= require jquery
//= require jquery_ujs

window.$ = window.jQuery = global.$ = require('jquery');

I am using the spockets jquery, react_ujs and jquery_ujs but using react from npm.

// application.js
//= require jquery
//= require jquery_ujs
//= require react_ujs

var React = window.React = global.React = require('react');
var ReactDOM = window.ReactDOM = global.ReactDOM = require('react-dom');

require('./components');

Great References: RAILS + REACT + NPM: ANOTHER OPTION and MODERN JAVASCRIPT AND RAILS