Why is my html reaction not working?

I wrote a simple response component, but it does not display HTML on the page. Can someone please direct me to where I am mistaken?

http://codepen.io/NehhaSharma/pen/EVNdJJ?editors=101

Thanks.

<div id="content"></div>
<script type="text/jsx">

var newComponent = React.createClass({
    render : function(){
        return (
            <h2>My Name is React</h2>
        );
    }

});

React.render(<newComponent/>,document.getElementById('content'));
</script>
+4
source share
1 answer

Your component name must begin with an uppercase letter. From React Docs :

To display the React component, simply create a local variable that starts with an uppercase letter:

The following is displayed below:

<div id="content"></div>
<script type="text/jsx">

var NewComponent = React.createClass({
    render : function(){
        return (
            <h2>My Name is React</h2>
        );
    }

});

React.render(<NewComponent/>,document.getElementById('content'));
</script>
+18
source

Source: https://habr.com/ru/post/1609343/


All Articles