Update with-react-i18next example to use react-i18next@8.0.6 #5368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5352 . This updates the example updating react-i18next to v8.0.6, replacing the
translate
HOC towithNamespaces
andI18n
toNamespacesConsumer
.There is one thing that I am not sure if is correct or not so I need some guidance. You gotta wrap the page with the
withI18next
HOC so it will extend thegetInitialProps
of the page with this:The problem lies in
i18n.getInitialProps
that has this code:In my understanding, among other things, it gets the
i18n
object from the request (included by theserver.js
) and uses the data to createinitialI18nStore
andinitialLanguage
, and then return these two objects plus thei18n
object itself. If you add thei18n
object on the return, then there will be a crash on the client-side render of the page:TypeError: Cannot read property 'ready' of null
I don't know why, but returning it breaks
NamespacesConsumer
component fromreact-i18next
(the state becomes null). So I commented this line and the provider on_app.js
is getting thei18n
instance from thei18n.js
file (the same asserver.js
). I don't know if this would be an issue so I would like help to debug this.