Skip to content

Commit

Permalink
fix: fail accessing navigator on Node
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Jul 1, 2021
1 parent ca9716c commit 98ec6cc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export const rAF = __requestAnimationFrame
export const useIsomorphicLayoutEffect = IS_SERVER ? useEffect : useLayoutEffect

// This assignment is to extend the Navigator type to use effectiveType.
const navigatorConnection = (navigator as Navigator & {
connection?: {
effectiveType: string
saveData: boolean
}
}).connection
const navigatorConnection =
typeof navigator !== 'undefined' &&
(navigator as Navigator & {
connection?: {
effectiveType: string
saveData: boolean
}
}).connection

// Adjust the config based on slow connection status (<= 70Kbps).
export const slowConnection =
Expand Down

0 comments on commit 98ec6cc

Please sign in to comment.