From 664777e3b654daae01af4b9b94f5db5847879539 Mon Sep 17 00:00:00 2001 From: bbuilds Date: Mon, 16 Dec 2024 12:27:54 -0500 Subject: [PATCH] fix: :lipstick: localStorage for darkmode --- src/utils/useForcedDarkTheme.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/useForcedDarkTheme.ts b/src/utils/useForcedDarkTheme.ts index 29eb3eaa3..682153a48 100644 --- a/src/utils/useForcedDarkTheme.ts +++ b/src/utils/useForcedDarkTheme.ts @@ -1,11 +1,12 @@ import * as React from "react"; -import { useColorMode } from "@docusaurus/theme-common"; +import { useColorMode, ColorMode } from "@docusaurus/theme-common"; export function useForcedDarkTheme() { const { setColorMode, colorMode } = useColorMode(); //quick fix for updating color mode on page load breaking after theme upgrade React.useEffect(() => { - const originalTheme = colorMode; + const originalTheme = + (localStorage.getItem("theme") as ColorMode) ?? colorMode; //@ts-expect-error - The second parameter exists, it's just not on the type :( setColorMode("dark", { persist: false });