Browse Source

custom hook to detect if localStorage is loaded

Aykut Saraç 3 years ago
parent
commit
d3f9cca4d1
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/hooks/useLoading.tsx

+ 9 - 0
src/hooks/useLoading.tsx

@@ -0,0 +1,9 @@
+import { useEffect, useState } from "react";
+
+export const useLoading = () => {
+  const [loaded, setLoaded] = useState(false);
+
+  useEffect(() => setLoaded(true), []);
+  
+  return loaded;
+};