-
Notifications
You must be signed in to change notification settings - Fork 390
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
feat(core): add i18n.setCatalogAndActivate for easier nextjs integration #1541
feat(core): add i18n.setCatalogAndActivate for easier nextjs integration #1541
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## next #1541 +/- ##
==========================================
+ Coverage 75.17% 75.34% +0.16%
==========================================
Files 78 78
Lines 1962 1971 +9
Branches 512 515 +3
==========================================
+ Hits 1475 1485 +10
+ Misses 376 375 -1
Partials 111 111
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
443a224
to
bd20146
Compare
hello 👋
thanks :) |
@vonovak look at changes in this integration in nextjs https://github.com/lingui/swc-plugin/pull/38/files
i did not get the question |
Description
Fixes #1339
Integration with nextjs is not easy as it could be. You can check how much non-trivial code should be written https://github.com/lingui/swc-plugin/pull/38/files to make it work without accessing private properties of i18n.
This PR brings special method which
notify: false
which is crucial to make integration easy.The problem is in the race condition. When you setting locale or messages i18n emits an event. For that moment of time LinguiProvider already initialized and subscribed to the event from i18n. The emitting of this event happened inside react's "reconciliation phase" and it causes another
setState()
inside LinguiProvider which is not allowed during this phase.Simply disabling emitting event in this method fixes the issue and simplify integration a lot.
So instead
User have to write:
Types of changes
Checklist