GithubHelp home page GithubHelp logo

Server Side Errors about react_on_rails HOT 11 CLOSED

shakacode avatar shakacode commented on July 3, 2024
Server Side Errors

from react_on_rails.

Comments (11)

justin808 avatar justin808 commented on July 3, 2024

The good news is that you new get nice errors!

It looks like React is not exposed.

https://github.com/shakacode/react_on_rails/blob/master/spec/dummy/client/webpack.server.js#L25

Make sure that type of line is in both your client and server webpack files.

We handle common aspects like this: https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.common.config.js#L22 to avoid duplication.

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

@taylorbrooks Regarding server side, you should look in your config/initializers directory to see if you have an initializer. You might want to check that you're seeing the default that's setup here: https://github.com/shakacode/react_on_rails/blob/master/lib/react_on_rails/configuration.rb#L9. Maybe we have a bug? Default should be false.

from react_on_rails.

taylorbrooks avatar taylorbrooks commented on July 3, 2024

K, I'm a little farther, getting a different error now:

ERROR in ./~/react-chartjs/lib/core.js
Module not found: Error: Cannot resolve module 'expose' in /app/node_modules/react-chartjs/lib
 @ ./~/react-chartjs/lib/core.js 75:16-32

Which I think is failing on this line: https://github.com/jhudson8/react-chartjs/blob/master/lib/core.js#L79

I'm pretty new to webpack so I may need some n00b level guidance. 😄

from react_on_rails.

taylorbrooks avatar taylorbrooks commented on July 3, 2024

Nvm I fixed this ^^. Fixed the React undefined errors.

Getting this now (don't have anything in config/intializers):
screen shot 2015-09-21 at 7 47 18 pm

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

@taylorbrooks There's a bug in that the exception is caught and says server side even though ti's client side. I'm guessing that you have webpack configuration issues or maybe you didn't import CloseIoTemplates properly. Check out http://forum.railsonmaui.com/t/blackbelt-rails-debugging-techniques-with-react-server-rendering/351. Tips for debugging capybara tests! Same would apply to your situation.

from react_on_rails.

taylorbrooks avatar taylorbrooks commented on July 3, 2024

Yeah seems like CloseioTemplates is undefined, but idk why.

Here's some of the code:

webpack.config.js

module.exports = {
  entry: "./app/components/components.js",
  output: {
    filename: "bundle.js",
    path: __dirname + "/app/assets/javascripts"
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_module|bower_components)/,
        loader: 'babel'
      },
      { test: require.resolve('react'), loader: 'expose?React' },
    ]
  }
};

components.js

var CloseioTemplates = require('./closeio_templates.jsx');

closeio_templates.jsx

var React = require('react');
module.exports = React.createClass({
  propTypes: {
    templates: React.PropTypes.array
  },

  render: function(){
    return (
      <ul id="things" className="list-group">{
        this.props.templates.map(function(template){
          return(
            <li className="list-group-item" data-template-name={template.name} data-template-id={template.id}>
              <div>
                {template.name}
                <span className="pull-right"></span>
              </div>
            </li>)
        })
      }</ul>
    );
  }
});

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

@taylorbrooks Definitely create the simplest possible example, only client side rendering, one simple hello world component. Try copying from the spec/dummy app inside of react_on_rails. Baby steps to narrow down the issue.

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

FWIW, we only use import rather than require, and let/const rather than var.

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

@taylorbrooks Did you solve your issue?

from react_on_rails.

taylorbrooks avatar taylorbrooks commented on July 3, 2024

Wasn't doing window.ComponentName = var ComponentName

Figured it out. Thanks!

from react_on_rails.

justin808 avatar justin808 commented on July 3, 2024

@taylorbrooks Thanks. This is shown in the README.md as:

window.MyReactComponentApp = MyReactComponentApp;

from react_on_rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.