0

I have a map function which should dynamic show classNames. In this function i want to set the className dynamic. I tried to set the className also without the

$

But dosen't also not work

this.state.antwort.map((item,key) => <Col md={2} key={key} className={' ${item.gender == "Female" ? karteFemale : karteMann}' } > ... ) } 

But i got the error, that the classNames are undefined. So how can i set the classes flexible ?

2 Answers 2

1
className={item.gender === 'Female' ? karteFemale : karteMann} 
Sign up to request clarification or add additional context in comments.

Comments

0

@Nifiro's post was spot on!

You can also use the clsx package in the future if you want some complicated behavior and classnames.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.