Next.js Discord

Discord Forum

Optimize code condition

Unanswered
Japanese Bobtail posted this in #help-forum
Open in Discord
Japanese BobtailOP
Since the update of tailwindcss from v3 to v4 i have to change my code from this...

data-active={origin == item.link.split('/')[1]}

to this...
data-active={origin == item.link.split('/')[1] ? true : null}

Okay its not a big deal. Is it possible to add the data-active attribute only, if the condition is true?

Thanks for help.

0 Replies