Skip to content

Commit

Permalink
fix: issue 1728 when useSuspense is false and default ns
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 committed Mar 6, 2024
1 parent d95d697 commit 5b98721
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

0 comments on commit 5b98721

Please sign in to comment.