-
-
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
Memorized Components Being Unnecessarily Re-rendered #979
Comments
That is kind of a workaround and I actually have noticed that before. The problem is, sometimes I have to use |
I think there is no fix for this...we use Suspense in a very experimental way - outside of the only use case of react.lazy... a) there is a workaround moving memo in an own Suspense |
@jamuhl Ok, definitely a problem with |
funfact -> withTranslation uses |
Then it is really weird. As you can see in codesanbox, |
The only way to find out what happens would be to debug the react-dom reconciler as memo HOC gets handled there... 🤷♂️but that is a rabbit hole too deep for me 🥺 |
Barebone sample to reproduce: https://codesandbox.io/s/great-grothendieck-oof2w |
@matthewkwong2 This issue might be resolved by #1174 |
@jamuhl @adrai It seems like this issue was resolved already. I'd propose we close it 🎉. Side question: I was wondering if there are more things I can do to contribute to this project? Also, do you have any plans for next year and the future of react-i18next? I'd love to be apart of it 🥰 |
@tigerabrodi for react-i18next there are currently no bigger plans. For i18next we're somehow waiting for an outcome of https://github.com/unicode-org/message-format-wg . If there will be a new standard come out for i18n we might adapt that in future... In general...like said...we're more than happy for any help |
Describe the bug
When using
useTranslation
in a memorized component (eithermemo
orPureComponent
), the component is being unnecessarily re-rendered. For me, it seems that this only happens ifi18next-xhr-backend
is used. In the codesandbox sample, 1 extra render is fired. While the worst I have met (in rare situation) is 7 extra renders.Occurs in react-i18next version
[email protected]
To Reproduce
Just use
useTranslation
in a memorized componenthttps://codesandbox.io/s/react-i18next-test-wzj08
https://codesandbox.io/s/react-i18next-test-z4jx0 (extended by @jamuhl)
Expected behaviour
A memorized component should behave the same as a normal component in terms of utilizing
react-i18next
.Additional context
Original discussion: #710 (comment)
The text was updated successfully, but these errors were encountered: