Below is my code...
somarray.user.filter(function(ele, index) {
if(this.state.showAllUser == false) {
return (index < 3)
}
else {
return true
}
})
this isn't defined correctly in the function. Fix it by binding it so that it has the correct definition.
somarray.user.filter(function(ele, index) {
if(this.state.showAllUser == false) {
return (index < 3)
}
else {
return true
}
}.bind(this))