Download chakra-ui/packages/react/src/hooks/use-previous.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 228 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/hooks/use-previous.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/hooks/use-previous.ts
-
curl -L -o use-previous.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/hooks/use-previous.ts
228 Bytes
| "use client" | |
| import { useEffect, useRef } from "react" | |
| export function usePrevious<T>(value: T) { | |
| const ref = useRef<T | undefined>(undefined) | |
| useEffect(() => { | |
| ref.current = value | |
| }, [value]) | |
| return ref.current | |
| } | |