Skip to content

Commit

Permalink
build: bug 1691 npm run build
Browse files Browse the repository at this point in the history
  • Loading branch information
timheilman committed Feb 6, 2024
1 parent 83d2a1d commit 3c3f512
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
35 changes: 5 additions & 30 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,6 @@
const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
const getT = () => memoGetT;
const getNewT = () => alwaysNewT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
console.log('useState(getT())');
console.log(getT);
console.log(getT());
const [t, setT] = react.useState(getT);
let joinedNS = namespaces.join();
if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
Expand All @@ -674,35 +671,21 @@
} = i18nOptions;
isMounted.current = true;
if (!ready && !useSuspense) {
console.log('!ready !useSuspense');
if (props.lng) {
console.log('!ready !useSuspense props.lng');
loadLanguages(i18n, props.lng, namespaces, () => {
if (isMounted.current) {
console.log('1');
setT(getNewT);
}
if (isMounted.current) setT(getNewT);
});
} else {
console.log('!ready !useSuspense !props.lng');
loadNamespaces(i18n, namespaces, () => {
console.log('!ready !useSuspense !props.lng loadNamespacesCallback');
if (isMounted.current) {
console.log('2');
setT(getNewT);
}
if (isMounted.current) setT(getNewT);
});
}
}
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
console.log('3');
setT(getNewT);
}
function boundReset() {
if (isMounted.current) {
console.log('4');
setT(getNewT);
}
if (isMounted.current) setT(getNewT);
}
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
Expand All @@ -714,9 +697,7 @@
}, [i18n, joinedNS]);
const isInitial = react.useRef(true);
react.useEffect(() => {
console.log('8:09 before');
if (isMounted.current && !isInitial.current) {
console.log('8:09 inside');
setT(getT);
}
isInitial.current = false;
Expand All @@ -725,14 +706,8 @@
ret.t = t;
ret.i18n = i18n;
ret.ready = ready;
if (ready) {
console.log('returning 0', ret.t);
return ret;
}
if (!ready && !useSuspense) {
console.log('returning 1');
return ret;
}
if (ready) return ret;
if (!ready && !useSuspense) return ret;
throw new Promise(resolve => {
if (props.lng) {
loadLanguages(i18n, props.lng, namespaces, () => resolve());
Expand Down

0 comments on commit 3c3f512

Please sign in to comment.