Spaces:
Configuration error
Configuration error
Download web/apps/labelstudio/src/components/Form/Utils.ts from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 482 Bytes
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/components/Form/Utils.ts
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/apps/labelstudio/src/components/Form/Utils.ts
-
curl -L -o Utils.ts https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/components/Form/Utils.ts
482 Bytes
| import { type Dispatch, type SetStateAction, useEffect, useMemo, useState } from "react"; | |
| export const useValueTracker = <T>(value: T, defaultValue?: T): [T, Dispatch<SetStateAction<T>>] => { | |
| const initialValue = useMemo(() => { | |
| return (value ?? defaultValue ?? "") as T; | |
| }, [value, defaultValue]); | |
| const [finalValue, setValue] = useState<T>(initialValue); | |
| useEffect(() => { | |
| setValue(initialValue); | |
| }, [initialValue]); | |
| return [finalValue as T, setValue]; | |
| }; | |