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

Function useComponentPerRow

src/ui-react/common/index.tsx:85–123  ·  view source on GitHub ↗
(
  {
    relationshipId,
    relationships,
    rowComponent: Row = RowView,
    getRowComponentProps,
    separator,
    debugIds,
  }: (RemoteRowProps | LocalRowsProps | LinkedRowsProps) & {
    separator?: ReactElement | string;
  },
  getRowIdsHook: (
    relationshipId: Id,
    rowId: Id,
    relationships: RelationshipsOrRelationshipsId | undefined,
  ) => Ids,
  rowId: Id,
)

Source from the content-addressed store, hash-verified

83);
84
85export const useComponentPerRow = (
86 {
87 relationshipId,
88 relationships,
89 rowComponent: Row = RowView,
90 getRowComponentProps,
91 separator,
92 debugIds,
93 }: (RemoteRowProps | LocalRowsProps | LinkedRowsProps) & {
94 separator?: ReactElement | string;
95 },
96 getRowIdsHook: (
97 relationshipId: Id,
98 rowId: Id,
99 relationships: RelationshipsOrRelationshipsId | undefined,
100 ) => Ids,
101 rowId: Id,
102) => {
103 const [resolvedRelationships, store, localTableId] =
104 getRelationshipsStoreTableIds(
105 useRelationshipsOrRelationshipsById(relationships),
106 relationshipId,
107 );
108 const rowIds = getRowIdsHook(relationshipId, rowId, resolvedRelationships);
109 return (
110 <Wrap separator={separator} debugIds={debugIds} id={rowId}>
111 {arrayMap(rowIds, (rowId) => (
112 <Row
113 key={rowId}
114 {...getProps(getRowComponentProps, rowId)}
115 tableId={localTableId as Id}
116 rowId={rowId}
117 store={store}
118 debugIds={debugIds}
119 />
120 ))}
121 </Wrap>
122 );
123};
124
125export const getUseCheckpointView =
126 (getCheckpoints: (checkpointIds: CheckpointIds) => Ids) =>

Callers 2

LocalRowsViewFunction · 0.90
LinkedRowsViewFunction · 0.90

Calls 4

arrayMapFunction · 0.90
getPropsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…