var CommentList = React.createClass({
render: function () {
return (
<div className="commentList">
Hello, world!I am a CommentList.
</div>
);
}
});
var CommentBox = React.createClass({
render: function () {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList /> //ERROR
</div>
);
}
});
React.render(
React.createElement(CommentBox, null),
document.getElementById('content')
);
使用此代码,我收到以下错误消息: JSX 元素类型“CommentList”没有任何构造或调用签名。
相同的代码适用于纯 HTML/JS(遵循本教程:https ://facebook.github.io/react/docs/tutorial.html )
我不知道为什么 TypeScript 不喜欢它。将 Visual Studio 2013 与 TS 1.6 一起使用(http://blogs.msdn.com/b/typescript/archive/2015/09/16/announcing-typescript-1-6.aspx)