@@ -51,7 +51,7 @@ import {
5151 GridWidth ,
5252 Row as RowType ,
5353} from "./types" ;
54- import { useLayoutEffect , useMemo , useState , CSSProperties , useEffect , useRef } from "react" ;
54+ import { useMemo , useState , CSSProperties , useEffect , useRef } from "react" ;
5555import { match , __ } from "ts-pattern" ;
5656import { useBentoConfig } from "../BentoConfigContext" ;
5757import { assignInlineVars } from "@vanilla-extract/dynamic" ;
@@ -233,12 +233,12 @@ export function Table<
233233 . map ( ( c ) => c . id ?? c . accessor )
234234 . indexOf ( stickyLeftColumnsIds [ stickyLeftColumnsIds . length - 1 ] ) ;
235235
236- // Keep a style object for each sticky column, which will be updated by the useLayoutEffect below
236+ // Keep a style object for each sticky column, which will be updated by the useEffect below
237237 const [ stickyLeftColumnStyle , setStickyLeftColumnStyle ] = useState (
238238 { } as Record < string , CSSProperties >
239239 ) ;
240240
241- // Keep a state for the height of the first row of headers, which will be updated by the useLayoutEffect below
241+ // Keep a state for the height of the first row of headers, which will be updated by the useEffect below
242242 const [ stickyHeaderHeight , setStickyHeaderHeight ] = useState ( 0 ) ;
243243
244244 const tableContainerRef = useRef < HTMLDivElement > ( null ) ;
@@ -249,7 +249,7 @@ export function Table<
249249 /** Get the width of each sticky column (using the header width as reference) and use it to set the `left` of each sticky column.
250250 * Each sticky column must have as `left` the total width of the previous sticky columns.
251251 */
252- useLayoutEffect ( ( ) => {
252+ useEffect ( ( ) => {
253253 // Make this computation only if we have any data, because headers are not rendered when there are no rows
254254 // and we need them to get the column width.
255255 if ( data . length > 0 ) {
@@ -375,20 +375,24 @@ export function Table<
375375 rowIndex : number ,
376376 interactiveRow : boolean
377377 ) {
378- return cells . map ( ( cell , index ) => (
379- < CellContainer
380- { ...cell . getCellProps ( ) }
381- index = { rowIndex }
382- lastLeftSticky = { index === lastStickyColumnIndex }
383- style = { stickyLeftColumnStyle [ cell . column . id ] }
384- first = { index === 0 }
385- last = { ( index + 1 ) % flatColumns . length === 0 }
386- interactiveRow = { interactiveRow }
387- withDividers = { withDividers }
388- >
389- { cell . render ( "Cell" ) }
390- </ CellContainer >
391- ) ) ;
378+ return cells . map ( ( cell , index ) => {
379+ const { key, ...cellProps } = cell . getCellProps ( ) ;
380+ return (
381+ < CellContainer
382+ key = { key }
383+ { ...cellProps }
384+ index = { rowIndex }
385+ lastLeftSticky = { index === lastStickyColumnIndex }
386+ style = { stickyLeftColumnStyle [ cell . column . id ] }
387+ first = { index === 0 }
388+ last = { ( index + 1 ) % flatColumns . length === 0 }
389+ interactiveRow = { interactiveRow }
390+ withDividers = { withDividers }
391+ >
392+ { cell . render ( "Cell" ) }
393+ </ CellContainer >
394+ ) ;
395+ } ) ;
392396 }
393397
394398 const rowsToRender = virtualizeRows
@@ -581,6 +585,7 @@ function ColumnHeader<D extends Record<string, unknown>>({
581585 ) : null ;
582586
583587 const hasHeaderContent = column . Header || hint || sortIcon ;
588+ const { key : _key , ...headerProps } = column . getHeaderProps ( column . getSortByToggleProps ( ) ) ;
584589
585590 return (
586591 < Box
@@ -598,7 +603,7 @@ function ColumnHeader<D extends Record<string, unknown>>({
598603 className = { [ columnHeader ( { withDividers, first, lastLeftSticky } ) ] }
599604 background = { config . headerBackgroundColor }
600605 color = { config . headerForegroundColor }
601- { ...column . getHeaderProps ( column . getSortByToggleProps ( ) ) }
606+ { ...headerProps }
602607 textAlign = { column . align }
603608 { ...config . padding . header }
604609 >
0 commit comments