Skip to content

Server-side rendering caches components.js in development mode #58

@eins78

Description

@eins78

While investigating #57 I came across a bug which might be the cause for many of the problems people are experiencing while trying out server-side rendering:

The components.js file is cached, even in development mode!
That means changes are not picked up until the rails server is restartet, hich causes confusing errors like [React::Renderer] ReferenceError: MyComponent is not defined even when it clearly is included.

To reproduce:

  1. app/assets/javascripts/components.js:

    /** @jsx React.DOM */
    
    var DummyComponent = React.createClass({displayName: 'DummyComponent',
      render: function () {
        return (
          React.DOM.div(null, 
            this.props.text
          )
        );
      }
    });
  2. Put this in any view:

    =react_component('DummyComponent', {:text => 'Hello'}, {:prerender => true})
  3. bundle exec rails s

  4. load the page corresponding to the view from 2..

  5. add the following anywhere in app/assets/javascripts/components.js;

    throw "WTF"
  6. reload page – it does not throw

  7. restart server and reload page – does throw

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions