Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
306 Bytes
"use client"
import { useRef } from "react"
type InitFn<T> = () => T
export function useConst<T extends any>(init: T | InitFn<T>): T {
const ref = useRef(null)
if (ref.current === null) {
// @ts-ignore
ref.current = typeof init === "function" ? init() : init
}
return ref.current as T
}