react-rails icon indicating copy to clipboard operation
react-rails copied to clipboard

Uncaught ReferenceError: ReactDOM is not defined

Open IvRRimum opened this issue 11 years ago • 11 comments

Freshly installed, when i tryed to run hello world program, this error hapened: Uncaught ReferenceError: ReactDOM is not defined

This is my react:

var HelloWorld = React.createClass({
  render: function() {
    return (
      <p>
        Hello, <input type="text" placeholder="Your name here" />!
        It is {this.props.date.toTimeString()}
      </p>
    );
  }
});

setInterval(function() {
  ReactDOM.render(
    <HelloWorld date={new Date()} />,
    document.getElementById('example')
  );
}, 500);

Its saved inside /app/assets/javascripts/components/test.js.jsx file.

Rails 4.2.4 With Ruby 2.2.3

IvRRimum avatar Oct 14 '15 12:10 IvRRimum

http://stackoverflow.com/questions/33125669/uncaught-referenceerror-reactdom-is-not-defined

O_o Why arent't the newest version of React on master ?

IvRRimum avatar Oct 14 '15 12:10 IvRRimum

It's actually already on master: https://github.com/reactjs/react-rails/blob/master/lib/assets/javascripts/react_ujs.js.erb#L57

42ae avatar Oct 15 '15 16:10 42ae

The change from a single JS package to many modules has complicated the process for building React.js into the gem code, see full discussion here: https://github.com/reactjs/react-rails/pull/365

I'm on the road this week so I haven't had a chance to find a new way yet!

rmosolgo avatar Oct 15 '15 17:10 rmosolgo

Please try gem version 1.4.0 which includes React 0.14 and open an issue if you have any trouble!

rmosolgo avatar Oct 22 '15 19:10 rmosolgo

Have the same error on fresh install. react-rails (1.10.0) Could please anyone help?

kukula avatar Mar 28 '17 09:03 kukula

@kukula http://stackoverflow.com/questions/33125669/uncaught-referenceerror-reactdom-is-not-defined

IvRRimum avatar Mar 28 '17 09:03 IvRRimum

thanks for fast reply! so I can not use react_component view helper?

kukula avatar Mar 28 '17 09:03 kukula

You can. Go trough the answers on the stackoverflow question i posted. Loads of discussion and solutions there.

IvRRimum avatar Mar 28 '17 09:03 IvRRimum

I've checked answers, but I'm not calling ReactDOM.render, I'm using react_component view helper in my view. Question is not about React itself, question about this gem.

kukula avatar Mar 28 '17 09:03 kukula

@kukula Then you are asking at the wrong issue i guess. In this issue we discuss the problem with ReactDOM.render. Wish the best of luck to you!

IvRRimum avatar Mar 28 '17 09:03 IvRRimum

thank you, I'll create a new issue than.

kukula avatar Mar 28 '17 09:03 kukula