const healthItemStyle={
backgroundColor:'green'
};
const warningItemStyle={
backgroundColor:'yellow'
};
const errorItemStyle={
backgroundColor:'red'
};
const scenario = ['AppPulse Active','AppPulse Mobile','AppPulse Trace','BSM-Login','Service Portal'];
const scenarioHealth = ['health','warning','health','health','error'];
const items=scenario.map((item,index)=>{
return(
<ListItem style={`${scenarioHealth[index]}ItemStyle`}>
<ListItemText primary={item} secondary={scenarioHealth[index]}/>
</ListItem>
)
});
As shown in the code above, I want to be able to dynamically generate the variable name of the tag style attribute.
I have tried a lot, like ${scenarioHealth[index]}ItemStyle
but obviously this doesn't work. So ask you any good way?