Skip to content

Commit dfd4832

Browse files
committed
fix(useNetworkState): drop vendor-prefixed connection fallbacks
mozConnection and webkitConnection existed only on old Firefox for Android and pre-61 Chromium; every browser exposing the Network Information API today ships unprefixed navigator.connection. Firefox and Safari do not ship the API at all.
1 parent dcc2482 commit dfd4832

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/useNetworkState/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ export type UseNetworkState = {
6666
type: NetworkInformation['type'] | undefined;
6767
};
6868

69-
type NavigatorWithConnection = Navigator &
70-
Partial<Record<'connection' | 'mozConnection' | 'webkitConnection', NetworkInformation>>;
69+
type NavigatorWithConnection = Navigator & {connection?: NetworkInformation};
7170
const navigator = isBrowser ? (globalThis.navigator as NavigatorWithConnection) : undefined;
7271

73-
const conn: NetworkInformation | undefined =
74-
navigator && (navigator.connection ?? navigator.mozConnection ?? navigator.webkitConnection);
72+
const conn: NetworkInformation | undefined = navigator?.connection;
7573

7674
function getConnectionState(previousState?: UseNetworkState): UseNetworkState {
7775
const online = navigator?.onLine;

0 commit comments

Comments
 (0)