UNPKG

react-firehooks

Version:

Lightweight dependency-free collection of React hooks for Firebase

16 lines (15 loc) 798 B
import { onTokenChanged } from "firebase/app-check"; import { useListen } from "../internal/useListen.js"; import { LoadingState } from "../internal/useLoadingValue.js"; const onChange = (stableAppCheck, next, error) => onTokenChanged(stableAppCheck, next, error); /** * Returns and updates the current App Check token * @param appCheck Firebase App Check instance * @returns App Check token, loading state, and error * - value: App Check token; `undefined` if token is currently being fetched, or an error occurred * - loading: `true` while fetching the token; `false` if the token was fetched successfully or an error occurred * - error: `undefined` if no error occurred */ export function useAppCheckToken(appCheck) { return useListen(appCheck, onChange, () => true, LoadingState); }