I18nProvider remounts all the children, but not rerender
See original GitHub issueDescribe the bug
I18nProvider
implementation has a very unpleasant effect of changing own key when locale changes. It declares, that forceRenderOnLocaleChange force rerender of all children. Sorry, but its not a rerender, it’s full remount of it’s children. As a result React.memo is killed and state of all the components is reset. I have google map inside and its remount is slow and flickering
To Reproduce
export default function App() {
return <I18nProvider i18n={i18n}><PureComponentWithReactMemo></I18nProvider>
}
Expected behavior It would be great to have all the components just rerendered, not remounted. It is usually done with a trick like having state with counter and incrementing it by one every time we need children to be rerendered.
I cannot have a single global I18nProvider
as it remounts everything inside, the heavy components like maps are remounted with unpleasant flicker.
Additional context
- jsLingui version 3.11.1
- Babel version - not related
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:11 (4 by maintainers)
Top GitHub Comments
Was just running into this as well. I feel like having this behavior as a default is a weird choice.
probably just stupidity on my side: Didn’t realize the remount for quite some time and now have to refactor every use of
t
which is sad. Would have rather notices it earlier 😅plzzz stale bot 😃