Hi i am trying to use ternary operator for multiple cases.
below is the code snippet,
const status_color_to_icon_name = {
white: 'info',
orange: 'major',
}
const default_icon_name = 'icon1';
<Icon name={status_color_to_icon_name[item.color] ?? default_icon_name} color=
{item.color} />
the above works fine. it looks for item name based on item.color if no name found in status_color_to_icon_name based on item.color it returns default_icon_name
now i have other condition if item.color is ‘red’ then i want to use custom_icon
i have tried below,
const custom_icon ='icon2';
const status_color_to_icon_name = {
white: 'info',
orange: 'major',
}
const default_icon_name = 'icon1';
<Icon name={item.color === 'red' ? custom_icon_name :
status_color_to_icon_name[item.color] ?? default_icon_name} color=
{item.color} />
but the above doesnt seem correct. could someone help me with this. thanks.