react-i18next: withNamespaces is not a function
Im trying to migrate to the latest version (8.0.7) and start using the HOC inside my component. The things is that i have a library which contains all my UI kit elements. Over there we have some default labels as well that ofcourse also need to be multilanguage.
When running all this within storybook it all runs fine but when i install it via npm and then consume these elements i get this error:
caught TypeError: (0 , _reactI18next.withNamespaces) is not a function
The main application ofcourse also uses translations so maybe that can be related?
import i18n from 'i18next';
import { reactI18nextModule } from 'react-i18next';
import XHR from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
i18n
.use(XHR)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
load: 'languageOnly',
backend: {
loadPath: '../dist/locales/{{lng}}/{{ns}}.json'
},
fallbackLng: {
'en-US': ['en']
},
ns: ['uielements'],
defaultNS: 'uielements',
fallbackNS: 'uielements',
debug: false,
keySeparator: '##',
interpolation: {
escapeValue: false // not needed for react!!
},
react: {
wait: true,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
nsMode: 'default'
}
});
export default i18n;
And the component:
export default withNamespaces()(Dialog);
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (10 by maintainers)
@jamuhl Thanks a lot! didnt knew this was the actual problem. For now i will keep 2 instances of i18next as well so i can just ship the library to contain everything. Keeping the libs in sync is indeed a problem but that is overall just a versioning thing