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貢獻(xiàn)204條經(jīng)驗(yàn) 獲得超92個(gè)贊
教程會(huì)給你整個(gè)代碼,拿到它的 package.json 文件,這里面有教程里使用的react版本,替換自己的,然后 npm 安裝就好了.再看看新的react組件創(chuàng)建方式.

Caballarii
TA貢獻(xiàn)1123條經(jīng)驗(yàn) 獲得超629個(gè)贊
這個(gè)方法在react16里面被移除了,麻煩去找個(gè)新一點(diǎn)的教程,現(xiàn)在都是extends Component的形式,createClass太老太老了
添加回答
舉報(bào)
0/150
提交
取消