农民工024
2020-07-04 14:37
import React from 'react';
import './SubApp.css'
import CommentBox from './components/CommentBox';
import CommentList from './components/CommentList';
class SubApp extends React.Component{
constructor(props){
super(props);
this.state = {
comments:['This is my first replay']
};
this.addComment = this.addComment.bind(this);
}
addComment(msg){
this.setState({
comments:[...this.comments,msg]
});
}
render(){
const {comments} = this.state;
return(
<div className="SubApp">
<span>TEST</span>
<CommentList messages={comments}/>
<CommentBox
commentsLength={comments.length}
onAddComment={this.addComment}
/>
</div>
);
}
}
export default SubApp;
在index.js 绑定的是哪个,就是加载显示的那个组件
老铁 你看看 你的 index.js
基于实例的 React16 傻瓜课程
22387 学习 · 106 问题
相似问题