What I am trying to achieve with this is quite simple. I have an array of options/tags displayed in a div. I want the classes to change on click to simulate an "active" state. While I've seen a few snippets on codesandbox that I could use to achieve what I want, my curiosity still is why this wouldn't even trigger the class change.
The referenced event elements and id match...
const variantHandler = (e: any) => {
e.preventDefault()
const d = e.currentTarget
const c = () => {
variants.map((variant: any) => {
if (d.id !== variant.node.id) {
d.classList.remove('bg-gray-900', 'text-myGray', 'dark:bg-myGray', 'dark:text-gray-900')
//alert('reached remove')
}
else {
d.classList.add('bg-gray-900', 'text-myGray', 'dark:bg-myGray', 'dark:text-gray-900')
//alert('reached add')
}
})
}
c();
}