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:62var 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'));
2 回答
牛奶老哥哥
TA贡献204条经验 获得超92个赞
教程会给你整个代码,拿到它的 package.json 文件,这里面有教程里使用的react版本,替换自己的,然后 npm 安装就好了.再看看新的react组件创建方式.
Caballarii
TA贡献1123条经验 获得超629个赞
这个方法在react16里面被移除了,麻烦去找个新一点的教程,现在都是extends Component的形式,createClass太老太老了
添加回答
举报
0/150
提交
取消