Skip to content

Commit

Permalink
fix(web): verify window exists before attempting to access navigator (
Browse files Browse the repository at this point in the history
#666)

Fix an issue causing an SSR exception if `getCurrentState` is called.
  • Loading branch information
jspizziri committed May 5, 2023
1 parent 78f0428 commit 60b99f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/internal/nativeModule.web.ts
Expand Up @@ -107,7 +107,7 @@ const effectiveTypeMapping: Record<
const getCurrentState = (
_requestedInterface?: string,
): Pick<NetInfoState, Exclude<keyof NetInfoState, 'isInternetReachable'>> => {
const isConnected = navigator.onLine;
const isConnected = isWindowPresent ? navigator.onLine : false;
const baseState = {
isInternetReachable: null,
};
Expand Down

0 comments on commit 60b99f2

Please sign in to comment.