【发布时间】:2017-12-14 05:38:35
【问题描述】:
当我打开我的 html 文件时,我收到以下错误消息。
TypeError: undefined is not a function (near
'..._react2.default.createClass...')
(anonymous function)bundle.js 966
_webpack_require bundle.js 20
(anonymous function)bundle.js 73
_webpack_require bundle.js 20
(anonymous function)bundle.js 63
_webpack_require bundle.js 64
这是我的 HTML 代码
</head>
<body>
<div id="content"></div>
<script src="js/bundle.js"></script>
</body>
</html>
这是我的 app.js 文件
import firstComponent from './firstComponent'
这是我的第一个 component.js 文件
import React from 'react'
import ReactDOM from 'react-dom'
var CommentBox=React.createClass({
render:function(){
return(
<div className="CommentBox">
HelloWorldCommentBox
</div>
);
}
});
ReactDOM.render(
<commentBox/>,
document.getElementById('content')
);
请帮帮我
【问题讨论】:
-
commentBox应该是CommentBox -
@Rajesh 为什么?我怀疑错误来自
createClass在 16 中被删除的事实 -
@Li357 我不知道。
-
@Rajesh 在 15 中被弃用并被正式移除,见“打包”:reactjs.org/blog/2017/09/26/react-v16.0.html
标签: javascript reactjs