Skip to content

Commit

Permalink
document.body.dataset.theme가 undefined일 때 에러 발생하는 문제 해결 (09.28)
Browse files Browse the repository at this point in the history
document.body.dataset.theme가 undefined일 때 에러 발생하는 문제 해결 (09.28)
  • Loading branch information
seoko97 authored Sep 27, 2023
2 parents 79f2ba4 + 89f20ba commit 169e7b5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,18 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {
document.body.dataset.theme = colorMode;
}

function ThemeScript() {
const stringifyFn = String(setBodyDatasetByTheme);
const stringifyFn = String(setBodyDatasetByTheme);

const fnToRunOnClient = `(${stringifyFn})()`;

return <script dangerouslySetInnerHTML={{ __html: fnToRunOnClient }} />;
}
const fnToRunOnClient = `(${stringifyFn})()`;

return (
<html lang="ko">
<head>
<meta name="google-site-verification" content={GOOGLE_SITE_VERIFICATION} />
</head>
<body suppressHydrationWarning={true}>
<script dangerouslySetInnerHTML={{ __html: fnToRunOnClient }} />
<Analytics />
<ThemeScript />
<div className="relative min-h-screen w-full bg-primary pb-36 transition-[background-color]">
<Providers>
<Hydrate>
Expand Down

0 comments on commit 169e7b5

Please sign in to comment.