1.React组建中的事件写法(每次渲染组件中的事件自动调用的问题,或者组建渲染中的死循环问题)
<div className={'button'}
onClick={()=> this.buttonClick({
content: this.state.inputValue,
from: this.state.myid,
to: this.props.data[this.state.toindex]._id})
}>
发送
</div>
而不能写成:
<div className={'button'}
onClick={this.buttonClick({
content: this.state.inputValue,
from: this.state.myid,
to: this.props.data[this.state.toindex]._id})
}>
发送
</div>