@@ -7,7 +7,7 @@ import Button from '@clayui/button';
7
7
import { ClayToggle as Toggle } from '@clayui/form' ;
8
8
import Icon from '@clayui/icon' ;
9
9
import Layout from '@clayui/layout' ;
10
- import React , { useMemo } from 'react' ;
10
+ import React , { useEffect , useLayoutEffect } from 'react' ;
11
11
12
12
import { ChildrenFunction , Collection , useCollection } from '../collection' ;
13
13
import { Item , Menu } from '../drop-down' ;
@@ -36,6 +36,9 @@ const Header = React.forwardRef<HTMLLIElement, HeaderProps>(
36
36
}
37
37
) ;
38
38
39
+ const useIsomorphicEffect =
40
+ typeof window === 'undefined' ? useEffect : useLayoutEffect ;
41
+
39
42
type Props < T > = {
40
43
/**
41
44
* Children content to render a dynamic or static content.
@@ -68,12 +71,12 @@ function HeadInner<T extends Record<string, any>>(
68
71
visibleKeys : new Set ( visibleColumns . keys ( ) ) ,
69
72
} ) ;
70
73
71
- useMemo ( ( ) => {
74
+ useIsomorphicEffect ( ( ) => {
72
75
if ( visibleColumns . size === 0 ) {
73
76
onVisibleColumnsChange ( collection . getItems ( ) , 0 ) ;
74
77
}
75
78
onHeadCellsChange ( collection . getSize ( ) ) ;
76
- } , [ ] ) ;
79
+ } , [ collection . getSize ( ) ] ) ;
77
80
78
81
return (
79
82
< thead { ...otherProps } ref = { ref } >
0 commit comments