EmailCodeBlock
Live Editor
function subscribe(callback) { window.addEventListener("online", callback); window.addEventListener("offline", callback); return () => { window.removeEventListener("online", callback); window.removeEventListener("offline", callback); }; } function useOnlineStatus() { return useSyncExternalStore( subscribe, () => navigator.onLine, () => true ); } function ChatIndicator() { const isOnline = useOnlineStatus(); // ... } function useSyncExternalStore<Snapshot>( subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot ): Snapshot;
Result
Loading...