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

Method commit

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

Source from the content-addressed store, hash-verified

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