Skip to content
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

Improved performance on Table with a lot of columns (> 150) #942

Merged
merged 7 commits into from
Jan 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions source/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,15 @@ export default class Table extends PureComponent {
a11yProps['aria-describedby'] = id;
}

a11yProps.key = "Row" + rowIndex + "-" + "Col" + columnIndex;
a11yProps.className = cn('ReactVirtualized__Table__rowColumn', className);
a11yProps.style = style;
a11yProps.title = title;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move all these props to object literal and rename a11yProps to cellProps?


return (
<div
{...a11yProps}
key={`Row${rowIndex}-Col${columnIndex}`}
className={cn('ReactVirtualized__Table__rowColumn', className)}
style={style}
title={title}>
>
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like the crux of this fix is to avoid generating sub-optimal React.createElement boilerplate with an added function call and for-loop. But that's not obvious at a glance, and might regress later.

I'd suggest adding a comment about why it's important not to mix inline props and spread props.

{renderedCell}
</div>
);
Expand Down Expand Up @@ -523,7 +525,7 @@ export default class Table extends PureComponent {
? SortDirection.ASC
: SortDirection.DESC;

const onClick = event => {
const onClick = event => {
Copy link
Owner

Choose a reason for hiding this comment

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

nit: trailing whitespace

sortEnabled &&
sort({
sortBy: dataKey,
Expand Down Expand Up @@ -553,12 +555,13 @@ export default class Table extends PureComponent {
a11yProps.id = id;
}

a11yProps.key = "Header-Col" + index;
a11yProps.className = classNames;
a11yProps.style = style;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same move and rename to headerProps

return (
<div
{...a11yProps}
key={`Header-Col${index}`}
className={classNames}
style={style}>
{...a11yProps}>
{renderedHeader}
</div>
);
Expand Down