MCPcopy Index your code
hub / github.com/TanStack/table / useQwikTable

Function useQwikTable

packages/qwik-table/src/index.tsx:33–72  ·  view source on GitHub ↗
(
  options: TableOptions<TData>
)

Source from the content-addressed store, hash-verified

31}
32
33export function useQwikTable<TData extends RowData>(
34 options: TableOptions<TData>
35) {
36 // Compose in the generic options to the user options
37 const resolvedOptions: TableOptionsResolved<TData> = {
38 state: {},
39 onStateChange: () => {},
40 renderFallbackValue: null,
41 ...options,
42 }
43
44 // Create a new table instance and store it in a Qwik store
45 const table = Qwik.useStore<{
46 instance: Qwik.NoSerialize<Table<TData>>
47 }>({
48 instance: Qwik.noSerialize(createTable(resolvedOptions)),
49 })
50
51 // By default, manage table state here using the table's initial state
52 const state = Qwik.useSignal(table.instance!.initialState)
53
54 // Compose the default state above with any user state. This will allow the user
55 // to only control a subset of the state if desired.
56 table.instance!.setOptions(prev => ({
57 ...prev,
58 ...options,
59 state: {
60 ...state.value,
61 ...options.state,
62 },
63 // Similarly, we'll maintain both our internal state and any user-provided
64 // state.
65 onStateChange: updater => {
66 state.value = updater instanceof Function ? updater(state.value) : updater
67 options.onStateChange?.(updater)
68 },
69 }))
70
71 return table.instance!
72}

Callers 4

main.tsxFile · 0.90
main.tsxFile · 0.90
main.tsxFile · 0.90
main.tsxFile · 0.90

Calls 1

createTableFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…