diff --git a/src/useTranslation.js b/src/useTranslation.js index 4b3abc308..2124b5469 100755 --- a/src/useTranslation.js +++ b/src/useTranslation.js @@ -38,7 +38,9 @@ export function useTranslation(ns, props = {}) { namespaces.every(n => hasLoadedNamespace(n, i18n)); // set states - const [t, setT] = useState({ t: i18n.getFixedT(null, namespaces[0]) }); // seems we can't have functions as value -> wrap it in obj + const [t, setT] = useState({ + t: i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]), + }); // seems we can't have functions as value -> wrap it in obj function resetT() { setT({ t: i18n.getFixedT(null, namespaces[0]) }); diff --git a/test/useTranslation.spec.js b/test/useTranslation.spec.js index 3343564ea..3e816ba5e 100644 --- a/test/useTranslation.spec.js +++ b/test/useTranslation.spec.js @@ -69,4 +69,37 @@ describe('useTranslation', () => { }); }); }); + + describe('few namespaces', () => { + function TestComponent() { + const { t, i18n } = useTranslation(['other', 'translation'], { i18n: i18nInstance }); + + expect(typeof t).toBe('function'); + expect(i18n).toEqual(i18nInstance); + + return