Skip to content

Commit 8211cde

Browse files
updated _app.js (#128)
* updated _app.js * removed comment
1 parent 2d704f1 commit 8211cde

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pages/_app.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { generateGlobalCssVariables } from '@/utils/theme-style-utils';
2-
import { useEffect } from 'react';
2+
import { useEffect, useState } from 'react';
33
import '../css/main.css';
44

55
export default function MyApp({ Component, pageProps }) {
66
const { global, ...page } = pageProps;
77
const { theme } = global || {};
8+
const [isMounted, setIsMounted] = useState(false);
89

910
const cssVars = generateGlobalCssVariables(theme);
1011

1112
useEffect(() => {
13+
setIsMounted(true);
1214
document.body.setAttribute('data-theme', page.colors || 'colors-a');
13-
});
15+
}, [page.colors]);
1416

1517
return (
1618
<>
@@ -19,7 +21,7 @@ export default function MyApp({ Component, pageProps }) {
1921
${cssVars}
2022
}
2123
`}</style>
22-
<Component {...pageProps} />
24+
{isMounted ? <Component {...pageProps} /> : null}
2325
</>
2426
);
2527
}

0 commit comments

Comments
 (0)