Rails, React, Browserify , react-rails gem - Cannot find module

1k Views Asked by At

I am following this great tutorial: setting-up-react-in-ruby-on-rails-part-1

I am getting this error: Error: Cannot find module xxx from xxx

test-component.es6.js

React   = require('react/addons');

let  TestTwo = require('./components/test-two.es6.js');

let TestComponent = React.createClass({
render() {
return (
  <div>
    <h1>{this.props.title}</h1>
    <TestTwo />
  </div>

);
}
});
module.exports = TestComponent;

component.js

//= require_tree ./components

// You'll probably want this if your using babel
require("babelify/polyfill");
var app = window.app = global.app = {};
//React bootstrap modules

var TestComponent = require('./components/test-component.es6.js');
app.TestComponent = TestComponent;

When I setup it this way it works but TestTwo component is no prerendered (I use prerender:true)

IMPORTANT EDIT

After server edit in this setup content get prerendered but I need to restart server every time Data is changed in browser but when I open Source View old data is there not new !?.

test-component.es6.js

React   = require('react/addons');

let TestComponent = React.createClass({
render() {
return (
  <div>
    <h1>{this.props.title}</h1>
    <app.TestTwo />
  </div>

);
}
});
module.exports = TestComponent;

component.js

//= require_tree ./components

// You'll probably want this if your using babel
require("babelify/polyfill");
var app = window.app = global.app = {};
//React bootstrap modules

var TestTwo = require('./components/test-two.es6.js');
app.TestTwo = TestTwo;

var TestComponent = require('./components/test-component.es6.js');
app.TestComponent = TestComponent;

TestTwo component is simply returning some text.

text.html.erb is same for both setups

<%= react_component 'app.TestComponent', {title:"Hello, Back"}, {prerender:true} %>

Win7 64-bit OS

0

There are 0 best solutions below