-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
t function from useTranslation is unstable in concurrent mode #1691
Comments
It seems to be caused by: react-i18next/src/useTranslation.js Line 117 in 4619862
|
Same issue here, and my react-i18next version is 12.3.1 |
same issue here. Thank you @woodreamz for your sleuthing so far. |
|
I have a draft PR to fix this at #1716 ; still working through the contribution checklist. testing-library/react-testing-library#1241 but I haven't looked into hook-testing support using it, yet |
Should be fixed with v14.0.2 |
Thank you @woodreamz for generating a minimal reproduction of the bug and @adrai for maintaining this repo and providing me the opportunity to contribute :) |
reverted with v14.0.3 and waiting for a better fix... because of this |
Sorry for the false start! I hope #1720 will be better forward progress. |
should be addressed with v14.0.5 |
This is still occurring for me in 14.0.5 |
I'm afraid I can reliably reproduce using the minimal reproduction from the original post in 14.0.3, and I cannot reproduce using 14.0.5 . I'm still interested in the bug; are you able to see the bug using the reproduction in the original post? If not, can you provide a different minimal reproduction with expected result vs actual result? |
I don't know if that's related or not. But having const tools = useMemo(() => {
console.log('useMemo')
return []
}, [t])
useEffect(() => {
console.log('useEffect')
}, [t])
|
🐛 Bug Report
The bug is really well explained in #1599. This issue has been also reported in #1636. Those issues have been closed without being fixed.
When enabling concurrent mode in React, the
t
function changes and creates extra renders. i18n.t is not doing that. For now, it's not major as concurrent mode is not enabled in production build but could become major in a futur react release.The issue seems to be in
useTranslation
. I am trying to find a fix and propose a PR. This issue will help to track the work.For now, concurrent mode is enabled with StrictMode.
To Reproduce
In this codesandbox, you can se in the console that the useEffect on i18n is called 2 times and the useEffect on t is called 3 times.
Expected behavior
useEffect with t as dependency should be called 2 times.
The text was updated successfully, but these errors were encountered: