我正在从React.js组件状态的教程做一些练习。我必须做编辑,删除和保存按钮到文档和textarea。我正在尝试做,但我的浏览器显示为空屏幕。我的代码:我有React.js状态的一些问题
<html>
<head>
<script src = "react-master/../js/react.js"></script>
<script src = "react-master/../js/react-dom.js"></script>
<script src = "js/browser.js"></script>
</head>
<body>
<div id = "example"></div>
<script type = "text/babel">
var Comment = React.createClass({
getInitialState: function(){
return {editing: false}
},
edit: function(){
this.setState({editing: true});
},
remove: function(){
console.log("Removing comments");
},
save: function(){
this.setState({editing: false});
},
renderNormal: function(){
return(
<div className = "comment-container">
<div className = "comment-text">{this.props.children}</div>
<button onClick = {this.edit}>Edit</button>
<button onClick = {this.remove}>Remove</button>
</div>
);
},
renderForm: function(){
return(
<div className = "comment-container">
<teaxtarea defaultValue = {this.props.children}></teaxtarea>
<button onClick = {this.save}>Save</button>
</div>
);
},
render: function(){
if (this.state.editing){
return this.renderForm;
}else{
return this.renderNormal;
}
}
});
ReactDOM.render(
<div className = "board">
<Comment>Hey now</Comment>
<Comment>Hey Anja</Comment>
<Comment>Hey Olga</Comment>
</div>,
document.getElementById("example"));
</script>
我犯了什么错误?