MCPcopy Index your code
hub / github.com/tinyplex/tinybase / useComponentPerRow

Function useComponentPerRow

src/ui-solid/common/index.tsx:88–129  ·  view source on GitHub ↗
(
  props: (RemoteRowProps | LocalRowsProps | LinkedRowsProps) & {
    separator?: JSXElement | string;
  },
  getRowIdsHook: (
    relationshipId: Id | (() => Id),
    rowId: Id | (() => Id),
    relationships: MaybeAccessor<RelationshipsOrRelationshipsId | undefined>,
  ) => () => Ids,
  rowId: Id | (() => Id),
)

Source from the content-addressed store, hash-verified

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

Callers 2

LocalRowsViewFunction · 0.90
LinkedRowsViewFunction · 0.90

Calls 2

contentFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…