Skip to content

Commit cdc39f9

Browse files
committed
[ui-react] Tolerance of missing context
1 parent e3ec932 commit cdc39f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ui-react/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const useThing = <
5959
isUndefined(id)
6060
? contextValue[offset]
6161
: isString(id)
62-
? objGet(contextValue[offset + 1] as IdObj<Thing>, id)
62+
? objGet((contextValue[offset + 1] ?? {}) as IdObj<Thing>, id)
6363
: id
6464
) as Thing;
6565
};
@@ -83,7 +83,7 @@ const useThingOrThingById = <
8383
};
8484

8585
export const useThingIds = (offset: number): Ids =>
86-
objIds(useContext(Context)[offset] as IdObj<unknown>);
86+
objIds((useContext(Context)[offset] ?? {}) as IdObj<unknown>);
8787

8888
export const useStore: typeof useStoreDecl = (id?: Id): Store | undefined =>
8989
useThing(id, 0);

0 commit comments

Comments
 (0)