next-i18next 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -87,6 +87,8 @@ After creating and exporting your `NextI18Next` instance, you need to take the f
87
87
  ```
88
88
  For more info, see [the NextJs section on custom servers](https://github.com/zeit/next.js#custom-server-and-routing).
89
89
 
90
+ Note: You can pass `shallowRender: true` into config options to avoid triggering getInitialProps when `changeLanguage` method is invoked.
91
+
90
92
  That's it! Your app is ready to go. You can now use the `NextI18Next.withTranslation` HOC to make your components or pages translatable, based on namespaces:
91
93
 
92
94
  ```jsx
@@ -249,6 +251,7 @@ MyPage.getInitialProps = async({ req }) => {
249
251
  | `strictMode` | `true` |
250
252
  | `use` (for plugins) | `[]` |
251
253
  | `customDetectors` | `[]` |
254
+ | `shallowRender` | `false` |
252
255
 
253
256
  _This table contains options which are specific to next-i18next. All other [i18next options](https://www.i18next.com/overview/configuration-options) can be passed in as well._
254
257
 
@@ -47,6 +47,7 @@ var defaultConfig = {
47
47
  },
48
48
  strictMode: true,
49
49
  errorStackTraceLimit: 0,
50
+ shallowRender: false,
50
51
 
51
52
  get initImmediate() {
52
53
  return !(0, _utils.isServer)();
@@ -117,7 +117,9 @@ var appWithTranslation = function appWithTranslation(WrappedComponent) {
117
117
  as = _lngPathCorrector.as,
118
118
  href = _lngPathCorrector.href;
119
119
 
120
- router.replace(href, as);
120
+ router.replace(href, as, {
121
+ shallow: config.shallowRender
122
+ });
121
123
  }
122
124
  };
123
125
 
@@ -35,6 +35,7 @@ export const defaultConfig = {
35
35
  },
36
36
  strictMode: true,
37
37
  errorStackTraceLimit: 0,
38
+ shallowRender: false,
38
39
 
39
40
  get initImmediate() {
40
41
  return !isServer();
@@ -44,7 +44,9 @@ export const appWithTranslation = function (WrappedComponent) {
44
44
  as: asPath,
45
45
  href: routeInfo
46
46
  }, newLng);
47
- router.replace(href, as);
47
+ router.replace(href, as, {
48
+ shallow: config.shallowRender
49
+ });
48
50
  }
49
51
  };
50
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-i18next",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "repository": "git@github.com:isaachinman/next-i18next.git",
5
5
  "author": "Isaac Hinman <isaac@isaachinman.com>",
6
6
  "funding": {
package/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export type InitConfig = {
23
23
  localeSubpaths?: Record<string, string>;
24
24
  use?: any[];
25
25
  customDetectors?: any[];
26
+ shallowRender?: boolean;
26
27
  } & InitOptions
27
28
 
28
29
  export type Config = {