fix: optimization calendar render performance
This commit is contained in:
parent
894ab6b9c3
commit
8f408f9050
@ -2,6 +2,7 @@ import React, { ReactChild } from "react";
|
|||||||
import { ViewMode } from "../../types/public-types";
|
import { ViewMode } from "../../types/public-types";
|
||||||
import { TopPartOfCalendar } from "./top-part-of-calendar";
|
import { TopPartOfCalendar } from "./top-part-of-calendar";
|
||||||
import {
|
import {
|
||||||
|
getCachedDateTimeFormat,
|
||||||
getDaysInMonth,
|
getDaysInMonth,
|
||||||
getLocaleMonth,
|
getLocaleMonth,
|
||||||
getWeekNumberISO8601,
|
getWeekNumberISO8601,
|
||||||
@ -177,7 +178,7 @@ export const Calendar: React.FC<CalendarProps> = ({
|
|||||||
const dates = dateSetup.dates;
|
const dates = dateSetup.dates;
|
||||||
for (let i = 0; i < dates.length; i++) {
|
for (let i = 0; i < dates.length; i++) {
|
||||||
const date = dates[i];
|
const date = dates[i];
|
||||||
const bottomValue = Intl.DateTimeFormat(locale, {
|
const bottomValue = getCachedDateTimeFormat(locale, {
|
||||||
hour: "numeric",
|
hour: "numeric",
|
||||||
}).format(date);
|
}).format(date);
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ type DateHelperScales =
|
|||||||
| "millisecond";
|
| "millisecond";
|
||||||
|
|
||||||
const intlDTCache = {};
|
const intlDTCache = {};
|
||||||
const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFormatOptions = {}): DateTimeFormat => {
|
export const getCachedDateTimeFormat = (locString: string | string[], opts: DateTimeFormatOptions = {}): DateTimeFormat => {
|
||||||
const key = JSON.stringify([locString, opts]);
|
const key = JSON.stringify([locString, opts]);
|
||||||
let dtf = intlDTCache[key];
|
let dtf = intlDTCache[key];
|
||||||
if (!dtf) {
|
if (!dtf) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user