From e8a40acfaff21ed84759f4f844b4b73298e932bf Mon Sep 17 00:00:00 2001 From: yashigani Date: Fri, 5 Apr 2019 19:16:35 +0900 Subject: [PATCH] Merge options by Trans component --- src/Trans.js | 5 +++-- src/context.js | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Trans.js b/src/Trans.js index 649196003..c731f10eb 100644 --- a/src/Trans.js +++ b/src/Trans.js @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; import HTML from 'html-parse-stringify2'; -import { getI18n, getHasUsedI18nextProvider, I18nContext } from './context'; +import { getI18n, getHasUsedI18nextProvider, I18nContext, getDefaults } from './context'; import { warn, warnOnce } from './utils'; function hasChildren(node) { @@ -204,7 +204,8 @@ export function Trans({ const t = tFromProps || i18n.t.bind(i18n); - const reactI18nextOptions = (i18n.options && i18n.options.react) || {}; + const options = (i18n.options && i18n.options.react) || {}; + const reactI18nextOptions = { ...getDefaults(), ...options }; const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; const defaultValue = diff --git a/src/context.js b/src/context.js index f0069f750..1fc7d8a63 100644 --- a/src/context.js +++ b/src/context.js @@ -58,8 +58,6 @@ export const initReactI18next = { type: '3rdParty', init(instance) { - setDefaults(instance.options.react); - instance.options.react = getDefaults(); setI18n(instance); }, };