0

I get the below error message when I open my html file.

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

This is my Html code

</head>
<body>
    <div id="content"></div>
    <script src="js/bundle.js"></script>
</body>
</html>

This is my app.js file import firstComponent from './firstComponent'

This is my first component.js file

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

Please Help me with this

4
  • 3
    commentBox should be CommentBox Commented Dec 14, 2017 at 5:41
  • 1
    @Rajesh Why? I suspect the error comes from the fact createClass was removed in 16 Commented Dec 14, 2017 at 5:49
  • @Li357 I'm not aware about that. Commented Dec 14, 2017 at 5:51
  • 1
    @Rajesh It was deprecated in 15 and officially removed, see "Packaging": reactjs.org/blog/2017/09/26/react-v16.0.html Commented Dec 14, 2017 at 5:56

1 Answer 1

1

The name of the component has to started with a capital letter and you have to use use the same name when you use the component.

The component is

<CommentBox/>

not

<commentBox/>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.