From 15fded75f9ba63d79ff8dd3b277ef2a38628d5e3 Mon Sep 17 00:00:00 2001 From: Alba Vilanova Cortezon Date: Thu, 16 May 2024 13:12:50 +0200 Subject: [PATCH] Fix bugs setting the dates with locale --- src/ts/components/dates/DatesProvider.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ts/components/dates/DatesProvider.tsx b/src/ts/components/dates/DatesProvider.tsx index 7742ae9..06b934c 100644 --- a/src/ts/components/dates/DatesProvider.tsx +++ b/src/ts/components/dates/DatesProvider.tsx @@ -4,6 +4,7 @@ import { } from "@mantine/dates"; import dayjs from "dayjs"; import React, { useEffect } from "react"; +import customParseFormat from 'dayjs/plugin/customParseFormat'; interface Props extends DatesProviderProps { /** Unique ID to identify this component in Dash callbacks. */ @@ -16,13 +17,12 @@ interface Props extends DatesProviderProps { const DatesProvider = (props: Props) => { const { settings, children, setProps, ...others } = props; const { locale } = settings; - - useEffect(() => { - const localeObject = window[`dayjs_locale_${locale}`]; - if (localeObject) { - dayjs.locale(locale, localeObject); - } - }, [locale]); + + const localeObject = window[`dayjs_locale_${locale}`]; + if (localeObject) { + dayjs.locale(locale, localeObject); + dayjs.extend(customParseFormat); + } return (