From c9eb4e3c42f509fea50de9e5f7597b090df63127 Mon Sep 17 00:00:00 2001 From: Thatsaphorn Atchariyaphap Date: Sun, 6 Apr 2025 18:26:48 +0200 Subject: [PATCH] Fixed an issue where the screen flickers when reloading the page. - Add theme detection based on cookies across layouts --- app/(root)/layout.tsx | 15 ++++++++++----- app/contact/layout.tsx | 17 +++++++++++------ app/legal/layout.tsx | 27 ++++++++++++++++----------- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/app/(root)/layout.tsx b/app/(root)/layout.tsx index ff31718..76a8669 100644 --- a/app/(root)/layout.tsx +++ b/app/(root)/layout.tsx @@ -5,20 +5,25 @@ import Nav from "@/components/Navbar/Nav"; import Footer from "@/components/Home/Footer/Footer"; import {ThemeProvider} from "@/components/provider/ThemeProvider"; import React from "react"; +import {cookies} from "next/headers"; export const metadata: Metadata = { title: "Rhein Software", description: "Rhein Software Development", }; -export default function RootLayout({ - children, - }: Readonly<{ +export default async function RootLayout({ + children, + }: Readonly<{ children: React.ReactNode; }>) { + const cookieStore = await cookies(); + const theme = cookieStore.get("theme")?.value === "dark" ? "dark" : "light"; + return ( - - + + +