mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-06 04:31:50 +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();
|
||||
}, [locale]);
|
||||
|
||||
if (dayjsLocale) {
|
||||
dayjs.locale({
|
||||
...dayjsLocale,
|
||||
weekStart: weekStartsOn ? (weekStartsOn === "monday" ? 1 : 0) : undefined,
|
||||
formats: {
|
||||
...dayjsLocale.formats,
|
||||
LT: timeFormat === "12h" ? "h:mm A" : "H:mm",
|
||||
},
|
||||
});
|
||||
if (!dayjsLocale) {
|
||||
// wait for locale to load before rendering content
|
||||
return null;
|
||||
}
|
||||
|
||||
dayjs.locale({
|
||||
...dayjsLocale,
|
||||
weekStart: weekStartsOn ? (weekStartsOn === "monday" ? 1 : 0) : undefined,
|
||||
formats: {
|
||||
...dayjsLocale.formats,
|
||||
LT: timeFormat === "12h" ? "h:mm A" : "H:mm",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<DayjsContext.Provider
|
||||
value={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue