Skip to content
Advertisement

how to toggle between two css classes with react

I’m trying to toggle between two classes dark mode and normal mode.

THis is the vanilla js eventlistener

JavaScript

This is the button that when clicked on, switches between the two modes. how can I achieve this with react

JavaScript

Advertisement

Answer

In this case you could use useRef:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement