MCPcopy
hub / github.com/TanStack/table / createTable

Function createTable

packages/table-core/src/core/table.ts:283–527  ·  view source on GitHub ↗
(
  options: TableOptionsResolved<TData>
)

Source from the content-addressed store, hash-verified

281}
282
283export function createTable<TData extends RowData>(
284 options: TableOptionsResolved<TData>
285): Table<TData> {
286 if (
287 process.env.NODE_ENV !== 'production' &&
288 (options.debugAll || options.debugTable)
289 ) {
290 console.info('Creating Table Instance...')
291 }
292
293 const _features = [...builtInFeatures, ...(options._features ?? [])]
294
295 let table = { _features } as unknown as Table<TData>
296
297 const defaultOptions = table._features.reduce((obj, feature) => {
298 return Object.assign(obj, feature.getDefaultOptions?.(table))
299 }, {}) as TableOptionsResolved<TData>
300
301 const mergeOptions = (options: TableOptionsResolved<TData>) => {
302 if (table.options.mergeOptions) {
303 return table.options.mergeOptions(defaultOptions, options)
304 }
305
306 return {
307 ...defaultOptions,
308 ...options,
309 }
310 }
311
312 const coreInitialState: CoreTableState = {}
313
314 let initialState = {
315 ...coreInitialState,
316 ...(options.initialState ?? {}),
317 } as TableState
318
319 table._features.forEach(feature => {
320 initialState = (feature.getInitialState?.(initialState) ??
321 initialState) as TableState
322 })
323
324 const queued: (() => void)[] = []
325 let queuedTimeout = false
326
327 const coreInstance: CoreInstance<TData> = {
328 _features,
329 options: {
330 ...defaultOptions,
331 ...options,
332 },
333 initialState,
334 _queue: cb => {
335 queued.push(cb)
336
337 if (!queuedTimeout) {
338 queuedTimeout = true
339
340 // Schedule a microtask to run the queued callbacks after

Callers 13

useVueTableFunction · 0.90
createSvelteTableFunction · 0.90
tableMethod · 0.90
useQwikTableFunction · 0.90
createAngularTableFunction · 0.90
useReactTableFunction · 0.90
createSolidTableFunction · 0.90
RowPinning.test.tsFile · 0.90
useTableFunction · 0.90
useTableFunction · 0.90

Calls 6

functionalUpdateFunction · 0.90
memoFunction · 0.90
getMemoOptionsFunction · 0.90
recurseColumnsFunction · 0.85
orderColumnsFunction · 0.85
mergeOptionsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…