Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit a40c2de

Browse files
committed
fix: get theme on inital load
1 parent 80d03ce commit a40c2de

File tree

3 files changed

+63
-18
lines changed

3 files changed

+63
-18
lines changed

frontend/package-lock.json

Lines changed: 58 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"jose": "^4.8.1",
2323
"moment": "^2.29.3",
2424
"next": "^12.3.1",
25+
"next-cookies": "^2.0.3",
2526
"next-http-proxy-middleware": "^1.2.4",
2627
"next-pwa": "^5.5.2",
2728
"react": "18.0.0",

frontend/src/pages/_app.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {
88
import { useColorScheme } from "@mantine/hooks";
99
import { ModalsProvider } from "@mantine/modals";
1010
import { NotificationsProvider } from "@mantine/notifications";
11-
import { getCookie, setCookies } from "cookies-next";
11+
import { setCookies } from "cookies-next";
1212
import { GetServerSidePropsContext } from "next";
13+
import cookies from "next-cookies";
1314
import type { AppProps } from "next/app";
1415
import { useEffect, useState } from "react";
1516
import Footer from "../components/Footer";
@@ -22,9 +23,7 @@ import globalStyle from "../styles/mantine.style";
2223
import { CurrentUser } from "../types/user.type";
2324
import { GlobalLoadingContext } from "../utils/loading.util";
2425

25-
function App(
26-
props: AppProps & { colorScheme: ColorScheme; environmentVariables: any }
27-
) {
26+
function App(props: AppProps & { colorScheme: ColorScheme }) {
2827
const { Component, pageProps } = props;
2928

3029
const systemTheme = useColorScheme();
@@ -91,6 +90,6 @@ export default App;
9190

9291
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => {
9392
return {
94-
colorScheme: getCookie("color-schema") || "light",
93+
colorScheme: cookies(ctx)["color-schema"] || "light",
9594
};
9695
};

0 commit comments

Comments
 (0)