你得到的错误,因为要存储的参考
this在
that你使用引用您的事件处理程序,其可变的,但你不使用它三元表达式来确定
className的
button元素。
您的代码:
<button onClick={ that.getComponent.bind(that, result.patientproblemimageid) } className={ (this.state.hover) ? // this should be that 'button round button-center btshow' : 'button round button-center bthide'}>Delete Image</button>当您更改为时
this.state.hover,
that.state.hover不会收到错误。
附带说明一下,您可以将上下文参数简单地传递给method,而不是将对它的引用存储
this在
that变量中。
map()
results.map(function (result) { //}, this);


