UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

23 lines (20 loc) 699 B
import {useCurrentLocale} from '../i18n/hooks/useLocale' import {intlCache} from '../i18n/intlCache' /** * Options for the `useNumberFormat` hook * * @public */ export type UseNumberFormatOptions = Intl.NumberFormatOptions /** * Returns an instance of `Intl.NumberFormat` that uses the currently selected locale, * and enables locale/language-sensitive number formatting. * * @param options - Optional options for the number formatter * @returns Instance of `Intl.NumberFormat` * @public */ export function useNumberFormat(options: UseNumberFormatOptions = {}): Intl.NumberFormat { const currentLocale = useCurrentLocale().id return intlCache.numberFormat(currentLocale, options) }