You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the default example for a controlled multiselect data grid, there are performance issues when the row count is 50+ (in the example it is 250, but still noticeable at 50 rows. We use the virtualized version in our project and still see the issue as there is still a lot of rows on the screen)
Create a wrapper for DataGridRow that takes an item instead of a render function
Memoize that component and use it instead of DataGridRow
Extract selectionCell to a const so it doesn't get recreated every time
Fixing this issue using the @fluentui-contrib/react-data-grid-react-window package took a little more work than just that as we need to
Use a custom compare for the React.memo to handle the style prop changes
Use a const that is created outside the component for DataGridBody.children so that function that returns the DataGridRow is constant
It would be nice if this example is changed to show the best practice to handle more rows, or there is a fix to enable better memoization without consumers having to build it themselves
There was a partial fix to this issue previously, but that only addressed uncontrolled selection (#29908)
@spmonahan Ideally looking for a code change so consumers don't have to create their own version of DataGridRow and memorize that. But if that's not possible, then I think at least documentation updates so it's more obvious how to avoid this performance issue
Component
DataGrid
Package version
9.56.1
React version
18.3.0
Environment
Current Behavior
Following the default example for a controlled multiselect data grid, there are performance issues when the row count is 50+ (in the example it is 250, but still noticeable at 50 rows. We use the virtualized version in our project and still see the issue as there is still a lot of rows on the screen)
https://stackblitz.com/edit/5esunr-kwsr6c?file=src%2Fexample.tsx
Selecting a single row is noticeably slow and takes a while after the click to indicate to the user the row has been selected.
The issue is, selecting just a single row causes every other row to re-render as the parent component is re-rendering
This is set up as the multiple select controlled example in the fluent v9 docs
Expected Behavior
Applying a couple changes to the code, I can ensure only the single row that is selected needs to be re-rendered
https://stackblitz.com/edit/5esunr-dk1pvn?file=src%2Fexample.tsx
The changes are
DataGridRow
that takes an item instead of a render functionDataGridRow
selectionCell
to a const so it doesn't get recreated every timeFixing this issue using the
@fluentui-contrib/react-data-grid-react-window
package took a little more work than just that as we need toReact.memo
to handle thestyle
prop changesDataGridRow
is constantIt would be nice if this example is changed to show the best practice to handle more rows, or there is a fix to enable better memoization without consumers having to build it themselves
There was a partial fix to this issue previously, but that only addressed uncontrolled selection (#29908)
Reproduction
https://stackblitz.com/edit/5esunr-kwsr6c?file=src%2Fexample.tsx
Steps to reproduce
Are you reporting an Accessibility issue?
None
Suggested severity
Medium - Has workaround
Products/sites affected
No response
Are you willing to submit a PR to fix?
no
Validations
The text was updated successfully, but these errors were encountered: