← React Beginner Questions - Set 7 Q62
React Beginner Questions - Set 7
function Badge({ tone, active }) {
const cls = `badge badge--${tone}${active ? ' badge--active' : ''}`;
return <span className={cls}>New</span>;
}
// or with an array, which reads better with several conditions
const cls = ['badge', `badge--${tone}`, active && 'badge--active']
.filter(Boolean).join(' ');