From 871a85d9343cf49646d13dc455c062efadcb959a Mon Sep 17 00:00:00 2001
From: Tom van der Lee <tom@vanderlee.io>
Date: Sat, 12 Feb 2022 11:33:52 +0100
Subject: Beatified code

---
 src/contexts/DarkMode.tsx | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

(limited to 'src/contexts/DarkMode.tsx')

diff --git a/src/contexts/DarkMode.tsx b/src/contexts/DarkMode.tsx
index 6dc1c31..90278ff 100644
--- a/src/contexts/DarkMode.tsx
+++ b/src/contexts/DarkMode.tsx
@@ -3,39 +3,43 @@ import {
   Context,
   createContext,
   ReactElement,
-  ReactNode, useEffect,
+  ReactNode,
+  useEffect,
   useMemo,
-  useState
+  useState,
 } from "react";
-import {ThemeConfig} from "bootstrap-darkmode";
+import { ThemeConfig } from "bootstrap-darkmode";
 
 interface DarkModeApi {
-  darkMode: boolean
-  toggle: () => void
+  darkMode: boolean;
+  toggle: () => void;
 }
 
-export const DarkModeContext = createContext<Partial<DarkModeApi>>({}) as Context<DarkModeApi>;
+export const DarkModeContext = createContext<Partial<DarkModeApi>>(
+  {}
+) as Context<DarkModeApi>;
 interface DarkModeProviderProps {
-  children: ReactNode
+  children: ReactNode;
 }
 
 export default function DarkModeProvider({ children }: DarkModeProviderProps) {
   const themeConfig = useMemo(() => new ThemeConfig(), []);
-  const [darkMode, setDarkMode] = useState(() => themeConfig.getTheme() === 'dark')
+  const [darkMode, setDarkMode] = useState(
+    () => themeConfig.getTheme() === "dark"
+  );
 
   useEffect(() => {
-    themeConfig.setTheme(darkMode ? 'dark' : 'light');
-  }, [darkMode])
+    themeConfig.setTheme(darkMode ? "dark" : "light");
+  }, [darkMode]);
 
   return (
     <DarkModeContext.Provider
       value={{
         darkMode,
-        toggle: () => setDarkMode(dm => !dm),
+        toggle: () => setDarkMode((dm) => !dm),
       }}
     >
-
       {children}
     </DarkModeContext.Provider>
-  )
+  );
 }
-- 
cgit v1.2.3

