Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors HighTable to stop passing the data object through component props and instead expose data-frame methods via a dedicated React context, aiming to reduce unnecessary re-renders (per #449).
Changes:
- Introduce
DataContext+useData()and split out method-only typing (DataFrameMethods) inDataContext.ts. - Wrap the table subtree with
DataContext.Providerand stop threadingdatathroughHighTable→DOM→Slice. - Update
useFetchCellsandSliceto consumedata/numRowsfrom context rather than props.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/providers/DataProvider.tsx |
Adds DataContext.Provider and refines typing for the keyed provider. |
src/contexts/DataContext.ts |
Defines DataContext, useData(), and method/metadata type splits for the data frame. |
src/hooks/useFetchCells.ts |
Switches to reading data and numRows from contexts. |
src/components/HighTable/Slice.tsx |
Removes data prop dependency; reads methods from useData() and updates call sites. |
src/components/HighTable/HighTable.tsx |
Stops passing data through DOM/Slice; passes data only where still needed (state providers). |
Comments suppressed due to low confidence (2)
src/components/HighTable/Slice.tsx:21
SlicePropsstill includesnumRowsPerPage, butSlicedoesn't read or forward that prop anywhere (it's only referenced in this type). Keeping unused props in the public signature makes it harder to tell what actually affects rendering—consider removing it fromSliceProps(or wiring it up if it should influence behavior).
type SliceProps = Pick<HighTableProps, 'numRowsPerPage' | 'onDoubleClickCell' | 'onError' | 'onKeyDownCell' | 'onMouseDownCell' | 'overscan' | 'renderCellContent' | 'stringify'>
src/components/HighTable/HighTable.tsx:26
- The comment says “The DataProvider is remounted on data change”, but the implementation actually keys/remounts
KeyedDataProvider(a child) whileDataProvideritself stays mounted. Updating this comment would avoid confusion when reasoning about what does/doesn’t reset across data changes (especially now thatDataContext.Providersits outside the keyed subtree).
// The DataProvider is remounted on data change, so everything is recreated.
// TODO(SL): if this becomes a performance issue, we can revisit this behavior, and update the
// state more granularly.
<DataProvider data={data}>
<State data={data} {...props}>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
see #449
context instead of props, to avoid rerenders.