Skip to content

Commit c4ef4b2

Browse files
authored
Fix error during SSR when first Table column is not a row header (#5160)
1 parent b47220f commit c4ef4b2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/react-aria-components/src/Table.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class TableCollection<T> extends BaseCollection<T> implements ITableCollection<T
3737
}
3838

3939
commit(firstKey: Key, lastKey: Key, isSSR = false) {
40-
this.updateColumns();
40+
this.updateColumns(isSSR);
4141
super.commit(firstKey, lastKey, isSSR);
4242
}
4343

44-
private updateColumns() {
44+
private updateColumns(isSSR: boolean) {
4545
if (!this.columnsDirty) {
4646
return;
4747
}
@@ -75,7 +75,7 @@ class TableCollection<T> extends BaseCollection<T> implements ITableCollection<T
7575

7676
this.headerRows = buildHeaderRows(columnKeyMap, this.columns);
7777
this.columnsDirty = false;
78-
if (this.rowHeaderColumnKeys.size === 0 && this.columns.length > 0) {
78+
if (this.rowHeaderColumnKeys.size === 0 && this.columns.length > 0 && !isSSR) {
7979
throw new Error('A table must have at least one Column with the isRowHeader prop set to true');
8080
}
8181
}

packages/react-aria-components/test/Table.ssr.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ describe('Table SSR', function () {
2424
<button onClick={() => setShow(true)}>Show</button>
2525
<Table aria-label="Table">
2626
<TableHeader>
27-
<Column isRowHeader>Foo</Column>
28-
<Column>Bar</Column>
27+
<Column>Foo</Column>
28+
<Column isRowHeader>Bar</Column>
2929
</TableHeader>
3030
<TableBody>
3131
<Row key="1">

0 commit comments

Comments
 (0)