Skip to content

Commit

Permalink
Merge pull request #935 from PsychedMagnet/patch-1
Browse files Browse the repository at this point in the history
Fix hooks being called conditionally in useTranslation
  • Loading branch information
jamuhl authored Sep 9, 2019
2 parents f41a24b + 3d2361f commit b9c1b1c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/useTranslation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { warnOnce, loadNamespaces, hasLoadedNamespace } from './utils';
export function useTranslation(ns, props = {}) {
// assert we have the needed i18nInstance
const { i18n: i18nFromProps } = props;
const ReactI18nContext = useContext(I18nContext);
const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = getHasUsedI18nextProvider()
? useContext(I18nContext) || {}
? ReactI18nContext || {}
: {};
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
Expand Down

0 comments on commit b9c1b1c

Please sign in to comment.