MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Table

Function Table

starters/hooks/src/Table.tsx:32–60  ·  view source on GitHub ↗
(props: TableProps)

Source from the content-addressed store, hash-verified

30export type TableProps = TableStateProps<object> & AriaTableProps & {children?: ReactNode};
31
32export function Table(props: TableProps) {
33 let state = useTableState({...props, showSelectionCheckboxes: false});
34 let ref = useRef<HTMLTableElement>(null);
35 let {collection} = state;
36 let {gridProps} = useTable(props, state, ref);
37
38 return (
39 <table {...gridProps} ref={ref} className="react-aria-Table">
40 <TableRowGroup type="thead">
41 {collection.headerRows.map(headerRow => (
42 <TableHeaderRow key={headerRow.key} item={headerRow} state={state}>
43 {[...headerRow.childNodes].map(column => (
44 <TableColumnHeader key={column.key} column={column} state={state} />
45 ))}
46 </TableHeaderRow>
47 ))}
48 </TableRowGroup>
49 <TableRowGroup type="tbody">
50 {[...collection.body.childNodes].map(row => (
51 <TableRow key={row.key} item={row} state={state}>
52 {[...row.childNodes].map(cell => (
53 <TableCell key={cell.key} cell={cell} state={state} />
54 ))}
55 </TableRow>
56 ))}
57 </TableRowGroup>
58 </table>
59 );
60}
61
62function TableRowGroup({type: Element, children}: {type: 'thead' | 'tbody'; children: ReactNode}) {
63 let {rowGroupProps} = useTableRowGroup();

Callers

nothing calls this directly

Calls 2

useTableStateFunction · 0.90
useTableFunction · 0.90

Tested by

no test coverage detected