我需要在第二天学习React并开始使用官方教程。一切都很好,直到我到达我的代码状态,我收到一个错误,我不知道如何解决它:
</head>
<body>
<div id="content"></div>
<!-- script type="text/babel" src="scripts/example.js"></script -->
<script type="text/babel">
var CommentBox = React.createClass( {
render: function() {
return (
<div className = "commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
<Comment />
</div>
);
}
});
var CommentList = React.createClass({
render: function () {
return (
<div className = "commentList">
<Comment author = "Michael Johnson">This is one
comment</Comment>
<Comment author = "Daniel Kammer">This is the 'second'
comment</Comment>
</div>
);
}
});
var CommentForm = React.createClass({
render: function () {
return (
<div className = "commentForm">
Hello, world! I am a CommentForm.
</div>
);
}
});
var Comment = React.createClass({
var md = new Remarkable();
render: function () {
return (
<div className = "comment">
<h2 className = "commentAuthor">
{this.props.author}
</h2>
*** ERROR IS GENERATED BY THE BELOW STATEMENT ***
{md.render(this.props.children.toString())}
</div>
);
}
});
本教程的其余部分继续使用md.render语句 - 所以我需要了解如何解决此错误
答案 0 :(得分:0)
可能由<Comment />
组件中的ComentBox
引起。子组件是Comment
组件正常工作所必需的,但封闭标签没有子级(this.prop.childrens
为null或未定义=&gt;方法toString
未声明)