I am looking to swap the colors of the active element in my project. Currently, both elements change style when clicked. How can I resolve this? Thanks!
function Language() {
const [isStyled, setIsStyled] = useState(false);
const toggleStyle = () => {
setIsStyled(!isStyled);
};
return (
<>
<ul className="lang">
{languages.map(({ code, name, country_code }) => (
<li key={country_code}>
<h4 onClick={() => {i18next.changeLanguage(code); toggleStyle()}} className={isStyled ? "cont" : "cont2"}>{name}</h4>
</li>
))}
</ul>
</>
);
}