M
M
maxemga2021-05-19 22:24:24
React
maxemga, 2021-05-19 22:24:24

How to implement dark theme logic in React app?

When learning React after writing websites, I constantly have questions, for example, how to implement a dark theme in React?
That is, on a regular site on pure JS, for example, at the click of a button, I would load different css files (there are 2 of them, one dark theme, the other light), but as far as I know in React this is bad practice and it will be correct somehow
differently off topic, but what is the correct way to write an adaptive in a React application? That is, just like on a regular site through media, or does React have its own modern solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Simkav, 2021-05-19
@maxemga

Store theme state in state and select classes based on theme state
Responsive via media as usual

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question