I'm trying to create a JS react function that will return true if a button is clicked and false if it isn't. Essentially like a toggle true or false. I tried this
export const isButtonClicked = () => {
const element = document.getElementsByClassName('button');
if (element.addEventListener('click')) {
return true;
} else {
return false;
}
};
But it didn't work. I am attaching the function to this
verticalCompact={isButtonClicked()}
Looking for some help. Thanks