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.
It is a note-worthy fact that no two devices can have same IP address. If, in any case 192.168.1.1 netgear login that happens then it can lead to “IP Conflict” which can render one of the devices or both devices useless inside the network in which they are connected
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