Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

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

Luke Vellaf9122080daf7
diff --git a/src/utils/dayjs.tsx b/src/utils/dayjs.tsx
index 3898f0c8b..ff6564792 100644
--- a/src/utils/dayjs.tsx
+++ b/src/utils/dayjs.tsx
@@ -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={{