(options?: DateFormatterOptions)
| 26 | * @param options - Formatting options. |
| 27 | */ |
| 28 | export function useDateFormatter(options?: DateFormatterOptions): DateFormatter { |
| 29 | // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused. |
| 30 | options = useDeepMemo(options ?? {}, isEqual); |
| 31 | let {locale} = useLocale(); |
| 32 | return useMemo(() => new DateFormatter(locale, options), [locale, options]); |
| 33 | } |
| 34 | |
| 35 | function isEqual(a: DateFormatterOptions, b: DateFormatterOptions) { |
| 36 | if (a === b) { |
no test coverage detected