There was an error while loading. Please reload this page.
1 parent ffdc8a7 commit 88bf03fCopy full SHA for 88bf03f
1 file changed
lib/hooks/useOnlineStatus.ts
@@ -3,11 +3,12 @@
3
import { useState, useEffect } from 'react';
4
5
export function useOnlineStatus(): boolean {
6
- const [isOnline, setIsOnline] = useState(
7
- typeof navigator !== 'undefined' ? navigator.onLine : true
8
- );
+ // Always initialize to true to match SSR and prevent hydration mismatches
+ const [isOnline, setIsOnline] = useState(true);
9
10
useEffect(() => {
+ // Sync with the actual browser status on mount
11
+ setIsOnline(typeof navigator !== 'undefined' ? navigator.onLine : true);
12
const handleOnline = () => setIsOnline(true);
13
const handleOffline = () => setIsOnline(false);
14
0 commit comments