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

Method commit

packages/react-aria-components/src/Table.tsx:182–211  ·  view source on GitHub ↗
(firstKey: Key, lastKey: Key, isSSR = false)

Source from the content-addressed store, hash-verified

180 }
181
182 commit(firstKey: Key, lastKey: Key, isSSR = false) {
183 this.updateColumns(isSSR);
184
185 this.firstKey = firstKey;
186 this.lastKey = lastKey;
187 this.rows = [];
188 for (let row of this.getRows()) {
189 let lastChildKey = (row as CollectionNode<T>).lastChildKey;
190 if (lastChildKey != null) {
191 let lastCell = this.getItem(lastChildKey) as GridNode<T> | null;
192 while (lastCell && lastCell.type !== 'cell') {
193 lastCell =
194 lastCell.prevKey != null
195 ? (this.getItem(lastCell.prevKey) as GridNode<T> | null)
196 : null;
197 }
198 if (lastCell) {
199 let numberOfCellsInRow = (lastCell.colIndex ?? lastCell.index) + (lastCell.colSpan ?? 1);
200 if (numberOfCellsInRow !== this.columns.length && !isSSR) {
201 throw new Error(
202 `Cell count must match column count. Found ${numberOfCellsInRow} cells and ${this.columns.length} columns.`
203 );
204 }
205 }
206 }
207 this.rows.push(row);
208 }
209
210 super.commit(firstKey, lastKey, isSSR);
211 }
212
213 private updateColumns(isSSR: boolean) {
214 if (!this.columnsDirty) {

Callers

nothing calls this directly

Calls 5

updateColumnsMethod · 0.95
getRowsMethod · 0.95
getItemMethod · 0.95
pushMethod · 0.80
commitMethod · 0.65

Tested by

no test coverage detected