Przeglądaj źródła

Added types for usePrevious

jnfrati 4 lat temu
rodzic
commit
e38ec9dff2
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      dashboard/src/shared/hooks/usePrevious.ts

+ 5 - 2
dashboard/src/shared/hooks/usePrevious.ts

@@ -1,7 +1,10 @@
 import { useEffect, useRef } from "react";
 
-export const usePrevious = (value: any, initialValue: any) => {
-  const ref = useRef(initialValue);
+export const usePrevious = <ValueType = any>(
+  value: ValueType,
+  initialValue: ValueType
+) => {
+  const ref = useRef<ValueType>(initialValue);
   useEffect(() => {
     ref.current = value;
   });