From 35ed423b8923f9555379a54712ddbe9f9844e32a Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Fri, 6 Oct 2023 17:45:24 +0200 Subject: [PATCH] Migrate `usePrevious` to TS --- src/hooks/{usePrevious.js => usePrevious.ts} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename src/hooks/{usePrevious.js => usePrevious.ts} (63%) diff --git a/src/hooks/usePrevious.js b/src/hooks/usePrevious.ts similarity index 63% rename from src/hooks/usePrevious.js rename to src/hooks/usePrevious.ts index b1f8ff82ea2d..279e8e4a3bf4 100644 --- a/src/hooks/usePrevious.js +++ b/src/hooks/usePrevious.ts @@ -2,12 +2,9 @@ import {useEffect, useRef} from 'react'; /** * A hook that returns the previous value of a variable - * - * @param {*} value - * @returns {*} */ -export default function usePrevious(value) { - const ref = useRef(value); +export default function usePrevious(value: T): T { + const ref = useRef(value); useEffect(() => { ref.current = value; }, [value]);