'React i18next - Change language does not re-render components that are memoized using React.memo
Currently we are using re-usable component library for our react projects that uses I18nextProvider and passed the i18n instance for the integrating applications. One of the application uses functional components that uses React.memo to handle different use case. For those components, when we change the language it doesn't triggers a re-render. When we manually did a change, then it gets reflected with the new language values. Is that possible to force a re-render for the components that uses React.memo when we change the language?
Whether any one faced similar issues? Does memoize will work for handling translation updates?
Solution 1:[1]
You probably did not pass t as memo dependency
const welcome = useMemo(() => <Trans t={t}>Welcome to React</Trans>, [t]);
btw: it might also be you do not need to memo at all...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | adrai |
