I have an array of items and I want to change the background of some of the items.
Checking via the bool you are gonna see that part in switch.
className={classes.Items} this is working but how can I pass className here?
const createClassName = (data) => {
const className = "Items";
switch (data.isRead){
case false:
return className + "Unread";
case true:
return className ;
}
};
{props.data.map((item) => (
<MenuItem
// className={classes.Items}
//className={createClassNameForNotificationNeededRow(item)}
key={item.key}
>
switchfor a boolean comparison (That could just be anif(){}else{}or evenreturn data.isRead ? className : className + "Unread") Also, yourclassName + "Unread"will not have a space between, so the result will be a single "ItemsUnread" class (Which may or may not be intentioal)