Skip to content

Commit

Permalink
Merge pull request #782 from IABTechLab/feature/fix-theme-mode-switching
Browse files Browse the repository at this point in the history
Fix: 💄 Color mode switching between pages
  • Loading branch information
bbuilds authored Dec 16, 2024
2 parents 27fed9b + 664777e commit 4de063b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/useForcedDarkTheme.ts
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down

0 comments on commit 4de063b

Please sign in to comment.