Skip to content

Commit 245c389

Browse files
anton-karlovskiyaddyosmani
authored andcommitted
[core] added a conditional to check if navigator is defined (#42)
1 parent 45aee68 commit 245c389

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

network/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useState, useEffect } from 'react';
1919
let unsupported;
2020

2121
const useNetworkStatus = initialEffectiveConnectionType => {
22-
if ('connection' in navigator && 'effectiveType' in navigator.connection) {
22+
if (typeof navigator !== 'undefined' && 'connection' in navigator && 'effectiveType' in navigator.connection) {
2323
unsupported = false;
2424
} else {
2525
unsupported = true;

save-data/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
let unsupported;
1818

1919
const useSaveData = (initialSaveDataStatus = null) => {
20-
if ('connection' in navigator && 'saveData' in navigator.connection) {
20+
if (typeof navigator !== 'undefined' && 'connection' in navigator && 'saveData' in navigator.connection) {
2121
unsupported = false;
2222
} else {
2323
unsupported = true;

0 commit comments

Comments
 (0)