-
-
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
Fix/bug 1691 make returned t function identical upon second effect run in strict mode #1716
Conversation
@medihack can you review this? |
testing-library/react-testing-library#1241 was just merged, but I haven't looked closely yet at it to see if hook-based testing support was added for useEffect double-run in strictMode |
OK, I went down a bit of a rabbit hole toward writing a unit test for this, but it looks like strictMode is integrated into @testing-library/react (which subsumed @testing-library/react-hooks) only for v18 of react and higher, whereas react-i18next is still supporting v16 of react. That precludes using the strictMode testing configuration, without which it's hard for me to see how to test this change otherwise than as described in the "To Reproduce" section of the issue. That reproduction is reliable and is indeed fixed by this change. |
//cc: @kachkaev |
I totally understand. This is a widely-depended-upon library that I'm certainly no expert with. I welcome any/all code review comments and/or edits by those more familiar with the code. The test @medihack added alongside the change for the issue of changing the provider-provided i18n instance is still passing, which is a good sign. This makes sense since the |
At first glance, it looks good. If there is no time pressure, I would take a deeper look and try it out on the weekend if that is ok for you. |
wonderful... thank you @medihack |
The PR looks good to me. I also gave it a quick test drive and got no problems (with shallow routing in Next.js). |
Thank you very much for your contributions... it's included in v14.0.2 |
Why!!!!!! Why!!!!! Damn! |
@jaredhan418 is right... this PR breaks the language change rendering... @timheilman can you have a look at it? @medihack can you assist? |
I temporarily reverted it with v14.0.3 |
That's unfortunate :-( And unfortunately, I don't have enough time right now. I'll try my best in the upcoming weeks, but it looks like a nasty issue to fix entirely. |
happy to take a look! Though of course I can't promise anything. Thanks @jaredhan418 for your testing and notifying of the breakage, and thanks @adrai for being so on-top of this repo. Reversion is obviously the right move. |
…f fixedT function, bad impl, breaks test that was introduced in parent commit, verifying bug here: i18next#1716 (comment)
* test: bug 1691 second attempt, add test for actual use of i18n.changeLanguage with useTranslation * fix: (pre-cleanup) bug 1691 cherry pick of 168b8f0: use memoization of fixedT function, bad impl, breaks test that was introduced in parent commit, verifying bug here: #1716 (comment) * fix: (pre-cleanup) bug 1691 fixing dev issue: regenerate a new t fn everywhere other than where the bug was occurring, and keep shallow routing working via dependency list of useCallback hook. Fixes test broken by parent commit. * style: cleanup debug messages for bug 1691 * build: bug 1691 npm run build
Checklist
npm run test
Checklist (for documentation change)