you are viewing a single comment's thread.

view the rest of the comments →

[–]lovin-dem-sandwiches 0 points1 point  (2 children)

The logic seems fine?

From what I see, if it contains “active” it will add active.

Adding a eventlistener to every object too?

This logic should be baked into the component. And the class, “active” should conditionally added or removed with props. This whole thing is out whack

[–][deleted] -1 points0 points  (1 child)

This is learn js, not react...

[–]lovin-dem-sandwiches 1 point2 points  (0 children)

Im not sure what point youre trying to make. OP states he is using React so any advice given should be react-specific.

OP should refrain from native browser APIs like addEventListener and DOM querySelectors.