Dynamic import of dayjs locale

This commit is contained in:
Ben Grant 2021-05-24 21:48:03 +10:00
parent a1677094f7
commit 6ed9c1e226
2 changed files with 10 additions and 12 deletions

View file

@ -77,8 +77,7 @@ const Event = (props) => {
useEffect(() => {
if (Array.from(supportedLocales).includes(i18n.language)) {
require(`dayjs/locale/${i18n.language}`);
dayjs.locale(i18n.language);
import(`dayjs/locale/${i18n.language}.js`).then(() => dayjs.locale(i18n.language));
}
}, [i18n.language]);