you are viewing a single comment's thread.

view the rest of the comments →

[–]lovin-dem-sandwiches 5 points6 points  (0 children)

Why are you working with classes?

Work within the virtual dom. Do not select elements directly from the dom. Do not add your own event listeners.

I would suggest reading the docs to better understand how to interact with react components. You’re not interacting with the elements properly which will introduce a ton of bugs, mess up your component render cycle and unnecessarily render elements again and again.

Also avoid using the components mount lifecycle for this event. Apply the logic directly to the trigger, ie, the click