0

What do I do when I run across this?

<div className="ui row myClass">

If myClass was the only class I would import the relevant style sheet and do this:

<div className={styles.myClass}>

This syntax does not work (not surprising) and I am not sure what to do:

<div className="ui row" {styles.myClass}>

Should I just boil it down to a class without tag selectors?

1 Answer 1

2

I may have misunderstood you, but if I got you right, what I'd do is simply using template literals, like so:

<div className={`ui row ${styles.myClass}`}>

Take into account, in the end, React components are just JS. That's the beauty of them. Just remember: now any JS expression, like props, etc., has to be with $ sign (between ${} instead of just {}).

Sign up to request clarification or add additional context in comments.

2 Comments

This is the normal way of doing it, there are libraries like "classNames" that assist you in completing this task.
what would the syntax look like with classNames?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.