Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Fix performance degradation #200

Merged
merged 2 commits into from
Nov 1, 2018
Merged

Conversation

Marc-Andre-Rivet
Copy link
Contributor

Fixes #198

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-200 November 1, 2018 20:02 Inactive
@@ -37,6 +38,10 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
private readonly tableFn: () => JSX.Element[][];
private readonly tableStyle = derivedTableStyle();

private calculateTableStyle = memoizeOne((style: Partial<IStyle>) => R.mergeAll(
this.tableStyle(DEFAULT_STYLE, style)
));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style_table rarely changes, merging it with DEFAULT_STYLE creates a new object each time, triggering lots of re-renders and layout reevaluations. Memoizing the value prevents those problematic re-renders from occurring and brings performance back to what it used to be.

Copy link
Contributor

@valentijnnieman valentijnnieman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, sounds good!

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit 3e720b7 into master Nov 1, 2018
@Marc-Andre-Rivet Marc-Andre-Rivet deleted the 3.1-issue198-performance branch July 18, 2019 12:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants