I'm currently working on toggling the CSS class for an individual button that is created from a mapped array.
Although my code is functional, it toggles the CSS class for all buttons in the mapped array instead of just the one selected.
<div className='synonym-keeper'>
{synArr.map((syn) => (
<button
className={`synonym ${isPressed && 'active'}`}
onClick={() => toggleIsPressed(!isPressed)}
>
{syn}
</button>
))}
</div>
How can I modify my code so that only the CSS class of the selected button toggles?