Check for existence of classes on click (React)
问题 I want to check to see if a particular element, when clicked, has a specified class. I know that you can bind a click handler which passes e.target to the handler. My thinking was to get e.target.classList.indexOf(this.myClass) > -1 to see if it has the class, but I get the following error. e.target.classList.indexOf is not a function I assume this is because classList is an array-like object, and not an actual array. Is there a simpler way to get a list of classes from a clicked element in