fix(ssr): attempt to fix theme flashing
All checks were successful
deploy / deploy (push) Successful in 1m2s

This commit is contained in:
Lee 2023-11-08 19:43:19 +00:00
parent 3341f07136
commit 736f286d66
2 changed files with 18 additions and 13 deletions

@ -1,4 +1,5 @@
import AppProvider from "@/components/AppProvider"; import AppProvider from "@/components/AppProvider";
import { ThemeProvider } from "@/components/ui/theme-provider";
import ssrSettings from "@/ssrSettings.json"; import ssrSettings from "@/ssrSettings.json";
import clsx from "clsx"; import clsx from "clsx";
import { Metadata } from "next"; import { Metadata } from "next";
@ -52,7 +53,14 @@ export default function RootLayout({
/> />
<body className={clsx(font.className, "text-primary")}> <body className={clsx(font.className, "text-primary")}>
<ThemeProvider
storageKey="ssr-theme"
attribute="class"
defaultTheme="dark"
enableSystem
>
<AppProvider>{children}</AppProvider> <AppProvider>{children}</AppProvider>
</ThemeProvider>
</body> </body>
</html> </html>
); );

@ -5,7 +5,6 @@ import { useSettingsStore } from "@/store/settingsStore";
import React from "react"; import React from "react";
import { ToastContainer } from "react-toastify"; import { ToastContainer } from "react-toastify";
import { TooltipProvider } from "./ui/Tooltip"; import { TooltipProvider } from "./ui/Tooltip";
import { ThemeProvider } from "./ui/theme-provider";
const UPDATE_INTERVAL = 1000 * 60 * 5; // 5 minutes const UPDATE_INTERVAL = 1000 * 60 * 5; // 5 minutes
@ -52,7 +51,6 @@ export default class AppProvider extends React.Component {
const props: any = this.props; const props: any = this.props;
return ( return (
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem>
<TooltipProvider> <TooltipProvider>
<ToastContainer <ToastContainer
className="z-50" className="z-50"
@ -62,7 +60,6 @@ export default class AppProvider extends React.Component {
/> />
{props.children} {props.children}
</TooltipProvider> </TooltipProvider>
</ThemeProvider>
); );
} }
} }