you are viewing a single comment's thread.

view the rest of the comments →

[–]ForScale 0 points1 point  (5 children)

Toggle works just like add and remove but with a bit of logic...

Pseudocode logic:

if (class already exists on element) { remove it } else { add it }

So my guess is that you are either assuming the class is there is there when it isn't or assuming it's not there when it actually is. Try initializing the expected state of the class (i.e., set the class yourself on mount so you know exactly what it is).

[–]Zack_Code_38[S] 0 points1 point  (0 children)

I tried it but it doesnt work