-
Notifications
You must be signed in to change notification settings - Fork 13
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
Performance concerns related to translate() #71
Comments
Hi ! you're right ;-)
But we probably should use memoization on 'getP' using 'createSelector' and
composing with 'getLocale' and 'getPhrases'. so object returned will be the
same until locale or phrases changes.
thanks for reporting :)
2017-01-22 1:28 GMT+01:00 André Cruz <notifications@github.com>:
… Hello!
I've been using the translate() enhancer for quite some time and, after
some experiments, I concluded that all components using translate are
being re-rendered after any dispatch(action).
All my components extend PureComponent which goes well with redux because
it avoids re-rendering components unless props have changed. The issue here
is that the p object changes every time because of this line:
https://github.com/Tiqa/redux-polyglot/blob/master/src/selectors.js#L52.
A new object is being created in mapStateToProps function which causes p
ref to change which makes all translated components to re-render.
The obvious solution here is to implement a custom shouldComponentUpdate
function that does a shallow compare for all properties, except for p
which needs to be deeply compared. While it works, it feels awkward to
delegate that responsibility to devs.
Am I missing something?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#71>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQHWeqaFnnuJ8NUKy1MjpUcQMEqz-ec7ks5rUqKpgaJpZM4LqOoF>
.
--
Guillaume ARM
+33 6 71 50 10 11
www.redpelicans.com
|
@guillaumearm sounds good! I'm getting huge perf issues on inputs, where a dispatch is being issued on every keypress. Do you have some free time to solve this issue? I can step in but I guess it would take much more time to do it. |
ok i will publish a new release candidate tonight about this ;-) |
using createSelector, in response to #71
I just published a patch on try it with a |
@guillaumearm I've tested the |
hum too bad. |
@satazor, I will try to use a memoized merge object to fix this. another solution would be to use |
done here : d69a9af Try it, and tell me if it's better ;-) |
I'm testing on a proprietary project but it's quite simple to test, just export a translated pure component and do a console.log inside render. You will see the print everytime you dispatch something (non related to polyglot). Thanks for this, will test in a few hours. |
@guillaumearm sorry for the delay. The behavior is still the same, will try to provide a fix. |
@guillaumearm I've added a test case in #75, will investigate a fix. Want to do this together? :D |
Yup, sure ^^ |
Add test for #71. Merged on a fix/rerender branch.
Merged, it is seems to be OK. @satazor you can test it on |
I'm currently on my phone, but will test asap. |
I confirm it's working! Thanks for fixing this! |
Hello!
I've been using the
translate()
enhancer for quite some time and, after some experiments, I concluded that all components usingtranslate
are being re-rendered after anydispatch(action)
.All my components extend
PureComponent
which goes well with redux because it avoids re-rendering components unless props have changed. The issue here is that thep
object changes every time because of this line: https://github.com/Tiqa/redux-polyglot/blob/master/src/selectors.js#L52. A new object is being created inmapStateToProps
function which causesp
ref to change and, consequently, causes all translated components to re-render.The user-land solution here is to implement a custom
shouldComponentUpdate
function that does a shallow compare for all properties except forp
, which needs to be deeply compared. While it works, it feels awkward to delegate that responsibility to devs.Am I missing something?
The text was updated successfully, but these errors were encountered: