I am new to reactjs. I have an array that will be
const mediumNames = ["TAMIL Medium", "ENGLISH MEDIUM"]
I have generated two cards using this code:
const [selectedMediumColor, setSelectedMediumColor] = useState('')
<div>
{mediumNames.map((text, index,) => (
<Card style={{ border: selectedMediumColor }} onClick={() => onClickMedium(text,index)} >
<div >
<img className={classes.imginCardBoard} src={TNlogo}></img>
<Typography className={classes.textinCardBoard} > { text} </Typography>
</div>
</Card>
))}
</div>
I want to set Border Color when clicking Cards in ReactJS. If the user selects the first card, the border color should be blue and the next card border color should be white and vice versa.
Here's the Function Code I wrote:
const onClickMedium = (medium,indexno) => {
console.log(medium)
console.log(indexno)
if (medium === "TAMIL Medium") {
selectedMediumColor('2px solid #00adb5')
}
else {
selectedMediumColor('')
}
}
it is setting the color for both cards. Here's the Image: enter image description here
I want the color to be set for one card only. How can I achieve this? Please Help me with some solutions.