Skip to main content
Bumped by Community user
manually rollback change in version 2, which left the answer by alexfertel somewhat invalidated
Source Link

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.totext} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.to} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.text} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

edited tags; edited title
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

ReactJS Conditionallink with conditional CSS Classesclasses

deleted 2 characters in body
Source Link
Bonteq
  • 153
  • 4

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.textto} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.text} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.

<Link key={link.to} href={link.to}>
    <a className={`border-transparent border-b-2 hover:border-blue-ninja ${
        activeClass === link.to ? 'active' : ''
    }`}>
        {link.text}
    </a>
</Link>

Is this best practice?

Source Link
Bonteq
  • 153
  • 4
Loading