Wait for dayjs locale to load before rendering (#254)

This commit is contained in:
Luke Vella 2022-07-28 12:20:07 +01:00 committed by GitHub
parent 8ced6bb2a4
commit f9122080da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,7 +96,11 @@ export const DayjsProvider: React.VoidFunctionComponent<{
return await dayjsLocales[locale ?? "en"].import();
}, [locale]);
if (dayjsLocale) {
if (!dayjsLocale) {
// wait for locale to load before rendering content
return null;
}
dayjs.locale({
...dayjsLocale,
weekStart: weekStartsOn ? (weekStartsOn === "monday" ? 1 : 0) : undefined,
@ -105,7 +109,6 @@ export const DayjsProvider: React.VoidFunctionComponent<{
LT: timeFormat === "12h" ? "h:mm A" : "H:mm",
},
});
}
return (
<DayjsContext.Provider