ChatGPT解决这个技术问题 Extra ChatGPT

Invariant Violation: _registerComponent(...): Target container is not a DOM element

I get this error after a making trivial React example page:

Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element.

Here's my code:

/** @jsx React.DOM */
'use strict';

var React = require('react');

var App = React.createClass({
  render() {
    return <h1>Yo</h1>;
  }
});

React.renderComponent(<App />, document.body);

HTML:

<html>
<head>
  <script src="/bundle.js"></script>
</head>
<body>
</body>
</html>

What does this mean?

@go-oleg: This is ES6 short notation. It's not the issue because react-tools has ES6 transpiler. See here
I ran into this same error, and as others have suggested, it's because your bundle.js file is loading too early. Move your