소스 검색

custom hook to detect if localStorage is loaded

Aykut Saraç 3 년 전
부모
커밋
d3f9cca4d1
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  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;
+};