mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-06 20:51:48 +02:00
Wait for dayjs locale to load before rendering (#254)
This commit is contained in:
parent
8ced6bb2a4
commit
f9122080da
1 changed files with 12 additions and 9 deletions
|
@ -96,17 +96,20 @@ export const DayjsProvider: React.VoidFunctionComponent<{
|
||||||
return await dayjsLocales[locale ?? "en"].import();
|
return await dayjsLocales[locale ?? "en"].import();
|
||||||
}, [locale]);
|
}, [locale]);
|
||||||
|
|
||||||
if (dayjsLocale) {
|
if (!dayjsLocale) {
|
||||||
dayjs.locale({
|
// wait for locale to load before rendering content
|
||||||
...dayjsLocale,
|
return null;
|
||||||
weekStart: weekStartsOn ? (weekStartsOn === "monday" ? 1 : 0) : undefined,
|
|
||||||
formats: {
|
|
||||||
...dayjsLocale.formats,
|
|
||||||
LT: timeFormat === "12h" ? "h:mm A" : "H:mm",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dayjs.locale({
|
||||||
|
...dayjsLocale,
|
||||||
|
weekStart: weekStartsOn ? (weekStartsOn === "monday" ? 1 : 0) : undefined,
|
||||||
|
formats: {
|
||||||
|
...dayjsLocale.formats,
|
||||||
|
LT: timeFormat === "12h" ? "h:mm A" : "H:mm",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DayjsContext.Provider
|
<DayjsContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue