Skip to content

Commit

Permalink
fix: issue 1728 when useSuspense is false and default ns (#1731)
Browse files Browse the repository at this point in the history
is custom, in strict mode only, memoization is performed of an unready translation function and is not refreshed after readiness.

The use of the isInitial ref is fundamentally incompatible with strict mode. Substituting ready instead seems to fix 1728 and keep both 1691 and 1718 fixed
  • Loading branch information
timheilman authored Mar 6, 2024
1 parent d95d697 commit a0c3d3e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,11 @@
if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
};
}, [i18n, joinedNS]);
const isInitial = react.useRef(true);
react.useEffect(() => {
if (isMounted.current && !isInitial.current) {
if (isMounted.current && ready) {
setT(getT);
}
isInitial.current = false;
}, [i18n, keyPrefix]);
}, [i18n, keyPrefix, ready]);
const ret = [t, i18n, ready];
ret.t = t;
ret.i18n = i18n;
Expand Down
Loading

0 comments on commit a0c3d3e

Please sign in to comment.