File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { generateGlobalCssVariables } from '@/utils/theme-style-utils' ;
2
- import { useEffect } from 'react' ;
2
+ import { useEffect , useState } from 'react' ;
3
3
import '../css/main.css' ;
4
4
5
5
export default function MyApp ( { Component, pageProps } ) {
6
6
const { global, ...page } = pageProps ;
7
7
const { theme } = global || { } ;
8
+ const [ isMounted , setIsMounted ] = useState ( false ) ;
8
9
9
10
const cssVars = generateGlobalCssVariables ( theme ) ;
10
11
11
12
useEffect ( ( ) => {
13
+ setIsMounted ( true ) ;
12
14
document . body . setAttribute ( 'data-theme' , page . colors || 'colors-a' ) ;
13
- } ) ;
15
+ } , [ page . colors ] ) ;
14
16
15
17
return (
16
18
< >
@@ -19,7 +21,7 @@ export default function MyApp({ Component, pageProps }) {
19
21
${ cssVars }
20
22
}
21
23
` } </ style >
22
- < Component { ...pageProps } />
24
+ { isMounted ? < Component { ...pageProps } /> : null }
23
25
</ >
24
26
) ;
25
27
}
You can’t perform that action at this time.
0 commit comments