Skip to content

Commit

Permalink
useSSR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Jul 2, 2019
1 parent bd16062 commit 83625ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 10.11.3

- only apply initial values in useSSR, withSSR on i18next instances not being a clone (eg. created by express middleware on server) ==> don't apply on serverside

### 10.11.2

- Reload translations whenever namespaces passed to useTranslation() change [878](https://github.com/i18next/react-i18next/pull/878)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "10.11.2",
"version": "10.11.3",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "src/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,10 @@
const _ref = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
i18nFromContext = _ref.i18n;

const i18n = i18nFromProps || i18nFromContext || getI18n(); // nextjs / SSR: getting data from next.js or other ssr stack
const i18n = i18nFromProps || i18nFromContext || getI18n(); // opt out if is a cloned instance, eg. created by i18next-express-middleware on request
// -> do not set initial stuff on server side

if (i18n.options && i18n.options.isClone) return; // nextjs / SSR: getting data from next.js or other ssr stack

if (initialI18nStore && !i18n.initializedStoreOnce) {
i18n.services.resourceStore.data = initialI18nStore;
Expand Down

0 comments on commit 83625ba

Please sign in to comment.