I have an object that contains multiple ids in an array:
"Headers" [
{
...
"listOfIds": [236, 242, 250, 289],
...
}
]
In my react component how can I use this array to compare if the ids in my redux store matches with any of the ones in the array. If it contains any of those ids, then I need to apply the class name to the variable.
My current code:
const reduxState = useSelector(state=> state);
_.map(Headers, (item, index) => {
const { listOfIds } = item;
let className = '';
if(_.get(reduxState, 'common.id', null) != listOfIds) {
className = 'hidden'
}
})
includesyour property value.Headersis, or why you're using_.mapwithout using the resulting array, or what you're going to do withclassName, since it loses scope once the map's iteration has completed...