React.createClass is not a function

index.js:4 Uncaught TypeError: React.createClass is not a function

    at Object.<anonymous> (index.js:4)

    at __webpack_require__ (bootstrap 76b8bc0f513264952518:19)

    at Object.<anonymous> (bundle.js:1183)

    at __webpack_require__ (bootstrap 76b8bc0f513264952518:19)

    at module.exports (bootstrap 76b8bc0f513264952518:62)

    at bootstrap 76b8bc0f513264952518:62




var React = require('react');

var ReactDOM = require('react-dom');


var CommentBox = React.createClass({

  render: function() {

    return (

      <div>

        Hello, world! I am a CommentBox.

      </div>

    );

  }

});

ReactDOM.render(

  <CommentBox />,

  document.getElementById('example')

);


LGX_TvT
浏览 4280回答 2
2回答

牛奶老哥哥

教程会给你整个代码,拿到它的 package.json 文件,这里面有教程里使用的react版本,替换自己的,然后 npm 安装就好了.再看看新的react组件创建方式.

Caballarii

这个方法在react16里面被移除了,麻烦去找个新一点的教程,现在都是extends Component的形式,createClass太老太老了
打开App,查看更多内容
随时随地看视频慕课网APP