olance / rails-react-browserify-example

This is an example/base Rails app for my article Rails, React, Browserify.
MIT License
22 stars 4 forks source link

Automaticly run reactify when .js.jsx files change #3

Open tnedich opened 9 years ago

tnedich commented 9 years ago

Can I automaticly run reactify again when .js.jsx files change. Now I need to quit rails server run rake tmp:cache:clear and then run rails server again. (Only when prerender is false)

EDIT

Whit prerender:true

In Google Chrome after I change something old data is rendered, but when I try to view page with Lynx new (changed data is rendered) - Strange :/

In source code view I see new data but in developer console and in browser ther is still old data rendered. If I quit server run rake tmp:cache:clear and then run rails server again old data is still there.

./components/header.js.jsx

var Header = React.createClass({
  propTypes: {
    name: React.PropTypes.string
  },

  render: function() {
    return (
      <div>
        <h1>Hello, {this.props.name}!</h1>
        <Test/>
      </div>
    );
  }
});

module.exports = Header;

./components/test.js.jsx

var Test = React.createClass({

  render: function() {
    return (
      <div>
        <h1>Test data</h1>
      </div>
    );
  }
});

module.exports = Test;

./components.js

// Tell react-rails where our components are
//= require_tree ./components

window.Test = require('./components/test');
window.Header = require('./components/header');
olance commented 9 years ago

Hi!

It might seem silly but have you tried restarting Chrome? I have found that it sometimes has that kind of cache problems...
Close your tab, clear Chrome's cached data and restart it if you haven't done so yet.

As far as I can tell, there's normally no need to restart Rails server or clear Rails tmp/cache when you modify your JSX files!