( id: Id | undefined, offset: Offsets, )
| 72 | : ((GLOBAL as any)[TINYBASE_CONTEXT] = createContext<ContextValue>([])); |
| 73 | |
| 74 | export const useThing = <UsedThing extends Thing>( |
| 75 | id: Id | undefined, |
| 76 | offset: Offsets, |
| 77 | ): UsedThing | undefined => { |
| 78 | const contextValue = useContext(Context); |
| 79 | return ( |
| 80 | isUndefined(id) |
| 81 | ? contextValue[offset * 2] |
| 82 | : isString(id) |
| 83 | ? objGet(contextValue[offset * 2 + 1] as IdObj<UsedThing>, id) |
| 84 | : id |
| 85 | ) as UsedThing; |
| 86 | }; |
| 87 | |
| 88 | export const useThings = <UsedThing extends Thing>( |
| 89 | offset: Offsets, |
no test coverage detected
searching dependent graphs…