This commit is contained in:
geoffsee
2025-05-22 23:14:01 -04:00
commit 33679583af
242 changed files with 15090 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { useEffect, useState } from "react";
const usePageLoaded = (callback: () => void) => {
const [isLoaded, setIsLoaded] = useState(false);
useEffect(() => {
const handlePageLoad = () => {
setIsLoaded(true);
callback();
};
if (document.readyState === "complete") {
// Page is already fully loaded
handlePageLoad();
} else {
// Wait for the page to load
window.addEventListener("load", handlePageLoad);
}
return () => window.removeEventListener("load", handlePageLoad);
}, [callback]);
return isLoaded;
};
export default usePageLoaded;