All files index.tsx

87.5% Statements 7/8
100% Branches 0/0
80% Functions 4/5
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23      6x               2x 2x 2x 2x 2x         2x    
import React, { useSyncExternalStore } from 'react';
 
function getSnapshot() {
  return navigator.onLine;
}
 
function getServerSnapshot() {
  return true;
}
 
function subscribe(callback: () => void) {
  window.addEventListener('online', callback);
  window.addEventListener('offline', callback);
  return () => {
    window.removeEventListener('online', callback);
    window.removeEventListener('offline', callback);
  };
}
 
export function useOnline() {
  return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}