【发布时间】:2019-04-24 18:18:01
【问题描述】:
我收到以下错误
未捕获的不变违规:预期
onClick侦听器是一个函数,而不是object类型的值。
当我在单击 div 时尝试将值(这是一个数组)传递给函数时。如果无法做到这一点,那么最好的处理方法是什么?
itemsArray(arr) {
let items = [];
let self = this;
const grouped = this.groupBy(arr, item => item.source);
grouped.forEach(function(value, key) {
switch(key.toString().toLowerCase()) {
case "occ_al": return items.push(<div onClick={self.listAllActivities(value)} className="recentActivityChannels"><img src={occ} width="15" /></div>)
}
})
items.push(<div className="clearFloat"></div>);
return items;
}
listAllActivities(arr){
let items = [];
var self = this;
const grouped = this.groupBy(arr, date => getDateServiceTab(date.date));
grouped.forEach(function(value, key) {
value.map((map) => {
//removed as its not important
return items;
}
【问题讨论】:
标签: javascript reactjs