First post in a long time so feeling a little out of the loop. Long stort short i'm in a little bit of a pickle. I created a navmenu pop out that toggles classname based on the isActive conditional. works beautifully in React but I can't work out how to impliment it in Next.js formatting using the classname={styles.selector syntax} if anyone can advise i'd be greatful. Code below
<div className={isActive? "drop-menu menu-2": null}> <a>text</a></div>
Use clsx library:
Example:
import clsx from 'clsx'
// ...
<div className={clsx(isActive ? "drop-menu menu-2" : null)}> <a>text</a></div>
// or
<div className={clsx(isActive && "drop-menu menu-2")}> <a>text</a></div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.