Filter list based on condition


#1

Need to help here. I am trying to list only items that belongs to a userID. I tried so many ways without getting any results. In other components I am using something like this and its working fine. Thank you. Best, Marcos

if (userID == ds_SlotUserID)


#2

Ok. Here’s the answer. Pretty simple. My little contribution to this community :slight_smile:

//Control user list
var userID = this.props.userID
var ds_SlotUserID = this.props.appActions.dataSlots[‘ds_SlotUserID’]
let filteredItems = [];
items.forEach(item => {;
if (item[‘userID’].includes(this.props.appActions.dataSlots[‘ds_SlotUserID’])) {
filteredItems.push(item);
}
});
items=filteredItems;
return items;