Skip to content

Commit f2b86a6

Browse files
committed
Address review comment
1 parent 18323c8 commit f2b86a6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/jsapi-bootstrap/src/useDeferredApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const DeferredApiContext = createContext<
2626
*/
2727
export function useDeferredApi(
2828
widget: DhType.ide.VariableDescriptor | UriVariableDescriptor | null
29-
): [dh: typeof DhType | null, error: unknown | null] {
29+
): [dh: typeof DhType | null, error: NonNullable<unknown> | null] {
3030
const [api, setApi] = useState<typeof DhType | null>(null);
31-
const [error, setError] = useState<unknown | null>(null);
31+
const [error, setError] = useState<NonNullable<unknown> | null>(null);
3232
const deferredApi = useContext(DeferredApiContext);
3333
const contextApi = useContext(ApiContext);
3434

@@ -63,7 +63,7 @@ export function useDeferredApi(
6363
setError(null);
6464
}
6565
} catch (e) {
66-
if (!isCancelled) {
66+
if (!isCancelled && e != null) {
6767
setApi(null);
6868
setError(e);
6969
}

packages/jsapi-bootstrap/src/useWidget.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ export function useWidget<T extends WidgetTypes = dh.Widget>(
112112
const wrapperWithApi = useMemo(
113113
() => ({
114114
...wrapper,
115-
error:
116-
wrapper.error ?? (descriptorApiError as NonNullable<unknown> | null),
115+
error: wrapper.error ?? descriptorApiError,
117116
api: wrapper.widget != null ? api : null,
118117
}),
119118
[wrapper, api, descriptorApiError]

0 commit comments

Comments
 (0)