Browse Source

allow toggles and storage of active theme

Sven Czarnian 2 years ago
parent
commit
e2a1dc6001
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/contexts/themecontext.tsx

+ 4 - 4
src/contexts/themecontext.tsx

@@ -1,4 +1,4 @@
-import React, { Dispatch, SetStateAction, useRef, useState } from 'react';
+import React, { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
 import { Session } from '../services';
 
 // TODO dynamic theming
@@ -17,10 +17,10 @@ export const ThemeProvider = ({ children }: { children: any }) => {
   const refDarkMode = useRef<boolean>();
   refDarkMode.current = darkMode;
 
-  //useEffect(() => {
-  //  Session.setTheme(refDarkMode.current ? 'dark' : 'light');
+  useEffect(() => {
+    Session.setTheme(refDarkMode.current ? 'dark' : 'light');
   //  window.location.reload();
-  //}, [darkMode]);
+  }, [darkMode]);
 
   //if (darkMode) {
   //  import('primereact/resources/themes/bootstrap4-dark-blue/theme.css');