@octanejs/i18next 0.1.51 → 0.1.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/i18next",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "peerDependencies": {
56
56
  "i18next": ">=26.2.0",
57
- "octane": "^0.6.0"
57
+ "octane": "^0.8.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@testing-library/jest-dom": "^6.9.1",
@@ -65,7 +65,7 @@
65
65
  "react-dom": "19.2.7",
66
66
  "react-i18next": "17.0.9",
67
67
  "vitest": "^4.1.10",
68
- "octane": "0.6.0"
68
+ "octane": "0.8.0"
69
69
  },
70
70
  "scripts": {
71
71
  "test": "vitest run"
@@ -277,9 +277,23 @@ export const useTranslation = (...args) => {
277
277
  subSlot(slot, 'ut:result'),
278
278
  );
279
279
 
280
+ // use() tracks thenables by call order, and a replay keeps the thenable
281
+ // already stored at a position. If this hook stopped calling use() once its
282
+ // namespaces loaded, the next use() in the component (a second
283
+ // useTranslation, or any other suspending read) would take this hook's
284
+ // position on the replay and receive this settled load instead of
285
+ // suspending on its own. Retain the load this call site suspended on and
286
+ // keep reading it after it settles. The key names what is being loaded, so
287
+ // settling never changes it.
288
+ const suspense = useMemo(
289
+ () => ({ promise: undefined }),
290
+ [i18n, props.lng, namespaces, useSuspense],
291
+ subSlot(slot, 'ut:suspense'),
292
+ );
280
293
  if (i18n && useSuspense && !ready) {
281
- use(getSuspenseLoadPromise(i18n, props.lng, namespaces));
294
+ suspense.promise = getSuspenseLoadPromise(i18n, props.lng, namespaces);
282
295
  }
296
+ if (suspense.promise !== undefined) use(suspense.promise);
283
297
 
284
298
  return ret;
285
299
  };