App.js:
import React, { PureComponent } from 'react'
import Commentitem from './components/Commentitem.js'
import Commentinput from './components/Commentinput.js'
export default class App extends PureComponent {
constructor(props){
super(props);
this.state={
commentlist:[]
}
}
render() {
return (
<div style={
{width:"500px",padding:"20px"}}>
{
this.state.commentlist.map((item,index)=>{
return <Commentitem key={item.id}
comment={item}
removeComment={e=>this.remove(index)}/>
})
}
<Commentinput submit={this.submit.bind(this)}/>
</div>
)
}
submit