-
Notifications
You must be signed in to change notification settings - Fork 836
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
Cache Child Props #1314
base: master
Are you sure you want to change the base?
Cache Child Props #1314
Conversation
Chris Thomas seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Using the 5th graph on the showcase (Line Chart Canvas - in svg mode) I was able to increase the fps while hovering over the graph from about 5 fps to 60 fps. To see this I changed the |
tests/utils/data-utils-tests.js
Outdated
@@ -56,7 +56,7 @@ test('data-utils #addValueToArray', t => { | |||
test('data-utils #transformValueToString', t => { | |||
t.deepEqual(transformValueToString(0), 0, | |||
'Shouldn\'t transform the number value'); | |||
t.deepEqual(transformValueToString(new Date(0)), 'Thu Jan 01 1970', | |||
t.deepEqual(transformValueToString(new Date(43200000)), 'Thu Jan 01 1970', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is 12:00 PM
which should play nicer with timezone differences.
src/plot/xy-plot.js
Outdated
@@ -187,6 +187,22 @@ class XYPlot extends React.Component { | |||
} | |||
}; | |||
|
|||
_childPropCache = Object.create(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit hestiant to add a cache instead of relying on useMemo. How about we wait till the modernization to React 16.8 (#1316) and useMemo instead (after some refactoring of this prop cloning behavior perhaps to using context)?
Alternatively, if you'd like to try out what this looks like via the modernize branch. Feel free to go for it.
d747435
to
a2e3f1c
Compare
Cache the child props to prevent React from re-rendering unnessesarily. The biggest culprits were the default accessors. The defaults for each attribute are now computed once, and re-used when required.
Cache the child props to prevent React from re-rendering unnessesarily.
The biggest culprits were the default accessors. The defaults for each
attribute are now computed once, and re-used when required.