MCPcopy
hub / github.com/tinyplex/tinybase / useCells

Function useCells

src/ui-react-dom/common/hooks.tsx:54–73  ·  view source on GitHub ↗
(
  defaultCellIds: Ids,
  customCells:
    Ids | {[cellId: Id]: string | CustomCell | CustomResultCell} | undefined,
  defaultCellComponent: CellComponent,
)

Source from the content-addressed store, hash-verified

52 );
53
54export const useCells = (
55 defaultCellIds: Ids,
56 customCells:
57 Ids | {[cellId: Id]: string | CustomCell | CustomResultCell} | undefined,
58 defaultCellComponent: CellComponent,
59): Cells<any> =>
60 useMemo(() => {
61 const cellIds = customCells ?? defaultCellIds;
62 return objMap(
63 isArray(cellIds)
64 ? objNew(arrayMap(cellIds, (cellId) => [cellId, cellId]))
65 : cellIds,
66 (labelOrCustomCell, cellId) => ({
67 ...{label: cellId, component: defaultCellComponent},
68 ...(isString(labelOrCustomCell)
69 ? {label: labelOrCustomCell}
70 : labelOrCustomCell),
71 }),
72 );
73 }, [customCells, defaultCellComponent, defaultCellIds]);

Callers 6

TableInHtmlTableFunction · 0.90
RelationshipInHtmlTableFunction · 0.90
ResultTableInHtmlTableFunction · 0.90
SortedTableInHtmlTableFunction · 0.90
SliceInHtmlTableFunction · 0.90

Calls 5

objMapFunction · 0.90
isArrayFunction · 0.90
objNewFunction · 0.90
arrayMapFunction · 0.90
isStringFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…