-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
DataTable
less prone to unnecessary re-renders
- Memo context provider values in various components. Otherwise every render of the component containing the `*.Provider` will cause any descendant consumers to re-render, even if the descendant has been memoed. Before this change, JSX like the following would result in a `DataTable` being re-rendered on every `Container` render: ``` function Container() { const table = useMemo(() => <DataTable ... />, [...]); return <Scroll>{table}</Scroll>; } ``` This happened because the `Scroll` component contained a context provider that was consumed by the `DataTable` and thus every render of the `Scroll` would re-render the `DataTable` child. - Memo rendered `DataTable` rows such that they only re-render if one of the following changes: - The row content - The columns - A custom `renderItem` callback - The selected row Users of `DataTable` can then more easily eliminate re-renders of large tables by memoing these props/callbacks.
- Loading branch information
1 parent
96c8318
commit b389fd5
Showing
6 changed files
with
88 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters