Home > AI > Frontend > ReactJS >

conditional add class

Example code:

import React from "react";

const Banner = ({ active, children }) => (
  <div className={`banner ${active ? "active" : ""}`}>{children}</div>
);

export default Banner;

Leave a Reply