Skip to content

Commit

Permalink
Fix darkmode undefined on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
chrsrns committed Nov 22, 2023
1 parent 7380e49 commit 8d26bb3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src-frontend-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const App: React.FC = () => {
const mainRowClassName = `row-offcanvas row-offcanvas-left ${
isActive ? "active" : ""
}`;
const [cookies] = useCookies(["accessToken", "darkmode"]);
const [cookies, setCookies] = useCookies(["accessToken", "darkmode"]);

// useEffect(() => {
// document.documentElement.setAttribute(
Expand All @@ -79,6 +79,8 @@ const App: React.FC = () => {
const socketConnected = useRef(false);

useEffect(() => {
if (cookies.darkmode === undefined) setCookies("darkmode", false);

if (cookies.darkmode) {
enableDarkMode({
brightness: 100,
Expand All @@ -87,7 +89,7 @@ const App: React.FC = () => {
} else {
disableDarkMode();
}
}, [cookies.darkmode]);
}, [cookies.darkmode, setCookies]);

const getLoggedInStatus = () => {
const data = { refreshToken: Cookies.get("refreshToken") };
Expand Down

0 comments on commit 8d26bb3

Please sign in to comment.