@orangecheck/design / useSpotPrice
Function: useSpotPrice()
function useSpotPrice(opts?: UseSpotPriceOptions): SpotPrice;
Defined in: format/use-spot-price.ts:73
Hook · returns the latest BTC/USD spot rate from endpoint.
Behaviour:
- First mount: synchronous return of
REFERENCE_BTC_USD(no NaN), then an async fetch updates state. - Every
intervalMsthereafter, a background fetch keeps the rate fresh while the tab is alive. - Network blips keep the last-good value — no flash to fallback.
- Unmount cancels both the in-flight read (
cancelledflag) and the interval timer.
Parameters
| Parameter | Type |
|---|---|
opts | UseSpotPriceOptions |