Warning: bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See user_list
在点击切换tab的时候 总会打印这个错误
Warning: bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See user_list
在点击切换tab的时候 总会打印这个错误
有相关代码嘛?看报错应该是给方法写了多余的bind,可以参考一下这个 https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding
<div className="list_top">
<input className="search" type="text" onChange={that.onInputChange.bind(that, 'name')} value={data.name} placeholder="名称/热线号"/>
<div className="btn_search" onClick={this.handleClick.bind(this)}>搜索</div>
</div>
有挺多这种写法的 百度到的说把bind(this)改成bind(null) 但是试过了 没有用。。。
handleClick: function () {
this.searchSession(this.state.data.name);
},
searchSession: function () {
var data = this.state.data;
var that = this;
var reqStr = "";
if (data.name) {
reqStr += "userInfo=" + data.name;
}
if(data.shopType && data.shopType!="类型"){
reqStr += "&shopType=" + data.shopType ;
}
if(data.area && data.area!="地区"){
reqStr += "&area=" + data.area;
}
//reqStr += "&shopType=" +
$.get('/im/user_list?' + reqStr, function (result) {
var data = that.state.data;
//console.log(data);
result.items.forEach(function (item) {
item.avatar = "http://7j1ztl.com1.z0.glb.clouddn.com/ " + item.avatar;
});
data['users'] = result.items;
that.setState({data: data});
}.bind(that));
},
把组件内部事件的.bind()移除,不需要在这里做bind操作。
onChange={that.onInputChange.bind(that, 'name')}
onClick={this.handleClick.bind(this)
如果你需要绑定this,在construtor执行bind