Download frontend/src/components/useRobReference.ts from Smart-Slate/Systematic-tool-review: direct link, hf CLI and curl.
- Browser
- Download file 799 Bytes
-
https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/useRobReference.ts
- Command line
-
hf download hf://spaces/Smart-Slate/Systematic-tool-review/frontend/src/components/useRobReference.ts
-
curl -L -o useRobReference.ts https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/useRobReference.ts
799 Bytes
| import { useEffect, useState } from "react"; | |
| import { getRobReference, peekRobReference } from "../api/protocols"; | |
| import type { RobReference } from "../types"; | |
| /** OHAT reference data (questions, designs, ratings), loaded once. */ | |
| export function useRobReference(): { reference: RobReference | null; error: string | null } { | |
| const [reference, setReference] = useState<RobReference | null>(() => peekRobReference()); | |
| const [error, setError] = useState<string | null>(null); | |
| useEffect(() => { | |
| let active = true; | |
| getRobReference() | |
| .then((ref) => active && setReference(ref)) | |
| .catch((err) => active && setError(err instanceof Error ? err.message : "Failed to load OHAT questions.")); | |
| return () => { | |
| active = false; | |
| }; | |
| }, []); | |
| return { reference, error }; | |
| } | |