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

perf(react-grid): avoid unnecessary row rerendering #1959

Merged
merged 12 commits into from Apr 19, 2019

Conversation

SergeyAlexeev
Copy link
Contributor

Fixes #1925

@SergeyAlexeev SergeyAlexeev changed the title [WIP]perf(react-grid): avoid unnecessary row rerendering perf(react-grid): avoid unnecessary row rerendering Apr 12, 2019

const propsAreEqual = argumentsShallowEqual(nextColumns, prevColumns)
&& argumentsShallowEqual(nextColSpans, prevColSpans)
&& prevRow === nextRow;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it is all about performance the prevRow === nextRow check should be moved to the beginning of the method.
Array lengths compare should be moved as well.

if (prevRow !== nextRow || prevCells.length !== nextCells.length) {
  return true;
}

It would allow to avoid unnecessary arrays creation and comparing.

shouldComponentUpdate(nextProps) {
const { cells: prevCells, row: prevRow } = this.props;
const { cells: nextCells, row: nextRow } = nextProps;
const [nextColumns, nextColSpans] = nextCells.reduce(reducer, [[], []]);
Copy link
Contributor

Choose a reason for hiding this comment

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

How about avoiding creation of two auxiliary arrays?

const areNotEqual = nextCells.some((nextCell, i) => {
  const prevCell = prevCells[i];
  return prevCell.column !== nextCell.column || prevCell.colSpan !== nextCell.colSpan;
});

@MaximKudriavtsev MaximKudriavtsev merged commit 5225f4a into DevExpress:master Apr 19, 2019
ushkal pushed a commit to ushkal/devextreme-reactive that referenced this pull request Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid - All rows are re-rendered when editing a row if VirtualTable is used
4 participants