React不渲染类

时间:2017-03-16 21:35:29

标签: javascript html reactjs sharepoint react-jsx

我相信我有一个语法区域,但我无法理解。

注意:我是React的新手,我正在使用Sharepoint进行开发。

我的Js文件:

var newt = React.createClass({
    getInitialState: function () {
        return {
            greeting: 'This is really',
            thing: 'code stuff'
        };
    },
    render: function () {
        return (
            <div id="react-newt">
                {this.state.greeting} {this.state.thing}!
            </div>
        );
    }
});

$(function () {
    if (document.getElementById('newt')) {
        React.render(
            <newt />,
            document.getElementById('newt')
        );
        console.log('newt');
    }
});

我的HTML文件:

<div id="newt"></div>

我检查控制台,我看到了这个: Console

1 个答案:

答案 0 :(得分:2)

您必须为组件使用大写名称。 JSX将小写视为内置HTML组件。有关详细信息,请参阅User-Defined Components Must Be Capitalized

concat("He said, ", '"', "I can't", '"')