File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
custom-implementation/src/components Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
2
3
- import { useEffect , useState } from 'react'
3
+ import { useEffect , useState , useRef } from 'react'
4
4
import {
5
5
ComponentConfigContext ,
6
6
HeaderV30 as SharedHeader ,
@@ -16,10 +16,17 @@ const Header = ({
16
16
} : // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
17
any ) => {
18
18
const html = document . getElementsByTagName ( 'html' ) [ 0 ]
19
- const [ theme , setTheme ] = useState ( html . getAttribute ( 'class' ) )
19
+ const [ theme , setTheme ] = useState ( html . getAttribute ( 'class' ) || 'light' ) // Default to 'light' if no class is present
20
+
21
+ const themeRef = useRef ( theme )
22
+ themeRef . current = theme
23
+
20
24
useEffect ( ( ) => {
21
25
const observer = new MutationObserver ( ( ) => {
22
- setTheme ( html . getAttribute ( 'class' ) )
26
+ const newTheme = html . getAttribute ( 'class' ) || 'light'
27
+ if ( themeRef . current !== newTheme ) {
28
+ setTheme ( newTheme )
29
+ }
23
30
} )
24
31
25
32
const config = { attributes : true , attributeFilter : [ 'class' ] }
@@ -39,7 +46,7 @@ any) => {
39
46
logo = { logo }
40
47
items = { links }
41
48
actions = { actions }
42
- version = { theme === 'dark' ? 'light ' : 'dark' }
49
+ version = { theme === 'dark' ? 'dark ' : 'light' } // Ensure the theme is correctly reflected
43
50
collapseOnScroll = { collapseOnScroll }
44
51
wrapperClassName = "custom-header"
45
52
/>
Original file line number Diff line number Diff line change 1
1
{
2
2
"organization" : " devrev" ,
3
- "version" : " 0.28 .0"
3
+ "version" : " 0.29 .0"
4
4
}
You can’t perform that action at this time.
0 commit comments