Open jothachil opened 4 years ago
According to the docs it looks like you could pass initialState as false. If that's getting overridden by the system default then maybe you could call a useEffect() hook with an empty array [] as the second parameter so it only runs once in page load. In that you'd do dark mode.disable to force it.
Best regards, Derek
Derek R. Austin, PT, DPT, MS, BCTMB, LMT, CSCS
Read my blog on Medium: https://medium.com/@DoctorDerek
Join me on LinkedIn: https://www.linkedin.com/in/derek-austin/
On Tue, Sep 22, 2020, 12:10 PM John Thachil notifications@github.com wrote:
if system prefer value is in dark mode the react app by default will start in dark mode is there any way the default value is always light mode?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/donavon/use-dark-mode/issues/60, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV42QV4CWJ52RHUF4BFIBLSHDD6JANCNFSM4RV64JYQ .
@djD-REK Got it. But the edge case here is even if the the default value is false and if system theme preference is set in auto. During the time system switch from light mode -> dark mode the react app will get changed to dark mode. Anyway I can enforce the change in theme is only by user action in the app.
I just modified the matchMedia of the window object to null as a work around
window.matchMedia = null;
const { value } = useDarkMode(true);
if system prefer value is in dark mode the react app by default will start in dark mode is there any way the default value is always light mode?