简体   繁体   中英

Intellij 15 showing errors in html with react components

I have the following code in my html:

<body>
<div id="greeting-div"></div>

<script type="text/babel">
    var Greeting = React.createClass({
        render: function() {
            return (
            <p>Hello, Universe</p>
            )
        }
    });
    ReactDOM.render(
        <Greeting/>,
        document.getElementById('greeting-div')
    );
</script>
</body>

Intellij is showing errors like "expression expected" near the left paren

return (

near the p tag

</p>

among other places. How to get rid of these errors?

Your code works fine, check.

 var Greeting = React.createClass({ render: function() { return ( <p>Hello, Universe</p> ) } }); ReactDOM.render( <Greeting/>, document.getElementById('greeting-div') ); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script> <div id="greeting-div"></div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM