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

Function useThingOrThingById

src/ui-react/context.ts:93–101  ·  view source on GitHub ↗
(
  thingOrThingId: T | Id | undefined,
  offset: Offsets,
)

Source from the content-addressed store, hash-verified

91 ({...useContext(Context)[offset * 2 + 1]}) as IdObj<UsedThing>;
92
93export const useThingOrThingById = <T extends Thing>(
94 thingOrThingId: T | Id | undefined,
95 offset: Offsets,
96): T | undefined => {
97 const thing = useThing(thingOrThingId as Id, offset);
98 return isUndefined(thingOrThingId) || isString(thingOrThingId)
99 ? (thing as T | undefined)
100 : (thingOrThingId as T);
101};
102
103export const useProvideThing = <Offset extends Offsets>(
104 thingId: Id,

Calls 3

isUndefinedFunction · 0.90
isStringFunction · 0.90
useThingFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…