-
Notifications
You must be signed in to change notification settings - Fork 843
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: EuiDataGrid don't recreate columns on every change #2676
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React, { | ||
Fragment, | ||
useState, | ||
useMemo, | ||
ReactChild, | ||
ReactElement, | ||
ChangeEvent, | ||
|
@@ -199,11 +200,18 @@ export const useColumnSelector = ( | |
</EuiPopover> | ||
); | ||
|
||
const orderedVisibleColumns = visibleColumns | ||
.map<EuiDataGridColumn>( | ||
columnId => | ||
availableColumns.find(({ id }) => id === columnId) as EuiDataGridColumn // cast to avoid `undefined`, it filters those out next | ||
) | ||
.filter(column => column != null); | ||
const orderedVisibleColumns = useMemo( | ||
() => | ||
visibleColumns | ||
.map<EuiDataGridColumn>( | ||
columnId => | ||
availableColumns.find( | ||
({ id }) => id === columnId | ||
) as EuiDataGridColumn // cast to avoid `undefined`, it filters those out next | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not filter first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think (although I am not sure, I just wrapped it with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, this looks like whitespace-only changes with the additional |
||
) | ||
.filter(column => column != null), | ||
[availableColumns, visibleColumns] | ||
); | ||
|
||
return [columnSelector, orderedVisibleColumns]; | ||
}; |
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.
We do accept that kind of size in Kibana so maybe it's worth to add it here?
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.
You could always make this dynamic through state, and let the user define it in the docs. The reason I kept it low was that I cared more about the docs page being snappy, then checking the performance of the grid itself. But now that you've made these changes it's a less a concern.
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 think you're right! The initial load time doesn't change so it's worth to lower it. Thank you for this comment!