소스 검색

Added types for usePrevious

jnfrati 4 년 전
부모
커밋
e38ec9dff2
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  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;
   });