-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
pureRender totally useless #22
Comments
It's really a problem.The state of LineChart is changing when mouse is moving in the chart, because we keep the location of mouse in state. |
The most condition is the reference of array or object. I use lodash isEqual function to re-write pureRender. It works faster.
|
Thanks, @arcthur. Yeah, it work faster now. The problem is not only for tooltip, but in managing state in common sense.
I think it would be better to store such auxiliary objects (like axisMaps and offset) to state, and perform shallow comparison for own LineChart props (nextProps) and children props (nextProps.children[].props) in componentWillReceiveProps. If that comparison will be false, we could recalculate these objects, otherwise just reuse previous state. Deep comparison seems like a brute force to achieve some performance boost, but it hides problem rather than solves it. |
Thanks @Cloudo to support the project, and welcome to provide the better codes to improve the recharts. 😄 Actually, |
Thanks @Cloudo for your enthusiasm.
The job involves so much components, may take longer. |
We optimized the pureRender function above official pureRender, that may be solved more problems. Always thanks! |
I just mentioned that
shallowCompare
method is totally useless for current version.I slightly changed
pureRender
decorator to store information about results ofshouldComponentUpdate
.After render LineChart and mouseovering for a while I got results:
The chart is almost totally rerender on any event yet it has the same data.
First of all, functions created in render should be refactored, cause it totally breaks pureRender.
More info here: https://medium.com/@esamatti/react-js-pure-render-performance-anti-pattern-fb88c101332f#.30axfnwr2
http://benchling.engineering/performance-engineering-with-react/
I tried to use another approach for some components and it works much faster:
...but I don't think that's a good solution.
guess we should find better way to deal with that problem...
The text was updated successfully, but these errors were encountered: