How do I dynamically import locales? #3460
Unanswered
SleeplessOne1917
asked this question in
Q&A
Replies: 1 comment
-
On v2 it works like this for me: import { setDefaultOptions } from 'date-fns';
...
export const loadDateFnsLocale = async (locale: Locale) => {
return await import(
`date-fns/locale/${localeToDateFnsLocale[locale]}/index.js`
);
};
export const useDateFnsLocale = () => {
const {data} = loadDateFnsLocale('en-US'); // Example
if (data) {
setDefaultOptions({ locale: data.default });
}
...
}; So basically seems you missed the index.js on your import |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
See this issue for context.
I set up the formatter like so:
You can see the error in the attached PR, and I can provide more information if needed.
Beta Was this translation helpful? Give feedback.
All reactions