@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
26 lines (22 loc) • 742 B
JavaScript
"use client";
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
let react = require("react");
react = require_rolldown_runtime.__toESM(react);
//#region src/hooks/use-online/index.ts
function subscribe(callback) {
window.addEventListener("online", callback);
window.addEventListener("offline", callback);
return () => {
window.removeEventListener("online", callback);
window.removeEventListener("offline", callback);
};
}
function getSnapshot() {
return window.navigator.onLine;
}
function useOnline(getServerSnapshot = () => true) {
return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
}
//#endregion
exports.useOnline = useOnline;
//# sourceMappingURL=index.cjs.map