I am in the process of creating a simple dark/light toggler button using React. Currently, I have developed a toggler component with a state defined as:
this.state = {style: './App.css'}
I have also created two functions – one that changes this.state.style
to ./darkmode.css
, and another that reverts it back to ./App.css
. These functions are linked to two buttons. My question is, would it be possible to import the value of this.state.style
directly into App.js rather than specifying it as ./App.css
? This approach seemed like the most straightforward way to switch between stylesheets for me. The CSS files simply control the camera effect and background color.