Im creating a datepicker component in React with typescript and my objective is to call The component
<Datepicker locale="pt-br" />
and pass like a string the Locale instead to import it and pass. And when this string arrives The datepicker component Will make The dynamic import.
1- Its possible to type all locales using the library date-fns with a import type? Or I have to declare all strings manually like:
type Locale = {
locale: 'ptBR' | 'enUS' | 'etc...'
}
2- Its possible to recive this string and make the import into the component?
The reason I dont want to import directly the locale like:
import {ptBR} from 'date-fns/locale'
and pass it as props, is because later I will create a library and i dont want that the user to install date-fns too to only pass this import
If is this possible tell me please, thank you guys.