@@ -37,41 +37,47 @@ export const columns: ColumnDef<LogEntry>[] = [
37
37
id : "expander" ,
38
38
header : ( ) => null ,
39
39
cell : ( { row } ) => {
40
- const [ localExpanded , setLocalExpanded ] = React . useState ( row . getIsExpanded ( ) ) ;
40
+ // Convert the cell function to a React component to properly use hooks
41
+ const ExpanderCell = ( ) => {
42
+ const [ localExpanded , setLocalExpanded ] = React . useState ( row . getIsExpanded ( ) ) ;
41
43
42
- // Memoize the toggle handler to prevent unnecessary re-renders
43
- const toggleHandler = React . useCallback ( ( ) => {
44
- setLocalExpanded ( ( prev ) => ! prev ) ;
45
- row . getToggleExpandedHandler ( ) ( ) ;
46
- } , [ row ] ) ;
44
+ // Memoize the toggle handler to prevent unnecessary re-renders
45
+ const toggleHandler = React . useCallback ( ( ) => {
46
+ setLocalExpanded ( ( prev ) => ! prev ) ;
47
+ row . getToggleExpandedHandler ( ) ( ) ;
48
+ } , [ row ] ) ;
47
49
48
- return row . getCanExpand ( ) ? (
49
- < button
50
- onClick = { toggleHandler }
51
- style = { { cursor : "pointer" } }
52
- aria-label = { localExpanded ? "Collapse row" : "Expand row" }
53
- className = "w-6 h-6 flex items-center justify-center focus:outline-none"
54
- >
55
- < svg
56
- className = { `w-4 h-4 transform transition-transform duration-75 ${
57
- localExpanded ? 'rotate-90' : ''
58
- } `}
59
- fill = "none"
60
- stroke = "currentColor"
61
- viewBox = "0 0 24 24"
62
- xmlns = "http://www.w3.org/2000/svg"
50
+ return row . getCanExpand ( ) ? (
51
+ < button
52
+ onClick = { toggleHandler }
53
+ style = { { cursor : "pointer" } }
54
+ aria-label = { localExpanded ? "Collapse row" : "Expand row" }
55
+ className = "w-6 h-6 flex items-center justify-center focus:outline-none"
63
56
>
64
- < path
65
- strokeLinecap = "round"
66
- strokeLinejoin = "round"
67
- strokeWidth = { 2 }
68
- d = "M9 5l7 7-7 7"
69
- />
70
- </ svg >
71
- </ button >
72
- ) : (
73
- < span className = "w-6 h-6 flex items-center justify-center" > ●</ span >
74
- ) ;
57
+ < svg
58
+ className = { `w-4 h-4 transform transition-transform duration-75 ${
59
+ localExpanded ? 'rotate-90' : ''
60
+ } `}
61
+ fill = "none"
62
+ stroke = "currentColor"
63
+ viewBox = "0 0 24 24"
64
+ xmlns = "http://www.w3.org/2000/svg"
65
+ >
66
+ < path
67
+ strokeLinecap = "round"
68
+ strokeLinejoin = "round"
69
+ strokeWidth = { 2 }
70
+ d = "M9 5l7 7-7 7"
71
+ />
72
+ </ svg >
73
+ </ button >
74
+ ) : (
75
+ < span className = "w-6 h-6 flex items-center justify-center" > ●</ span >
76
+ ) ;
77
+ } ;
78
+
79
+ // Return the component
80
+ return < ExpanderCell /> ;
75
81
} ,
76
82
} ,
77
83
{
0 commit comments