2017-12-14 5 views
0

htmlファイルを開くと、以下のエラーメッセージが表示されます。React JSのキャッチされていないタイプのエラー

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') 
); 

私を助けてくださいこれで

+3

'commentBox'が' CommentBox' – Rajesh

+1

@Rajeshなぜすべきですか?私は、エラーが 'createClass'が16で削除されたという事実によると思われます。 – Li357

+0

@ Li357私はそれについては気づいていません。 – Rajesh

答えて

1

コンポーネント名は大文字で始まり、コンポーネントを使用するときには同じ名前を使用する必要があります。

成分は

<CommentBox/>

でない

<commentBox/>

関連する問題