Skip to content

[refactor] use contexts with no intermediate hooks, and move logic to providers#463

Merged
severo merged 6 commits into
masterfrom
simplify
Mar 6, 2026
Merged

[refactor] use contexts with no intermediate hooks, and move logic to providers#463
severo merged 6 commits into
masterfrom
simplify

Conversation

@severo

@severo severo commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

see #449

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors internal state access to rely on direct useContext(...) reads (removing intermediate “useX” hooks) and moves some defaulting logic into providers/contexts to reduce rerenders and simplify memoization, aligning with issue #449.

Changes:

  • Replace custom context hooks (useViewportWidth, useHeaderHeight, useData, etc.) with direct useContext(Context) usage across providers/components/tests.
  • Introduce a default header/table-corner height via defaultTableCornerHeight and initialize TableCornerSizeProvider with that default.
  • Update provider tests to consume the raw contexts rather than removed hooks.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/providers/ViewportSizeProvider.test.tsx Updates test to use raw viewport contexts via useContext.
test/providers/TableCornerSizeProvider.test.tsx Updates test expectations for default header height and uses raw contexts.
test/providers/DataProvider.test.tsx Replaces custom hooks with raw contexts for provider verification.
src/providers/TableCornerSizeProvider.tsx Initializes table-corner height to a default and continues providing width/height/setter contexts.
src/providers/SelectionProvider.tsx Switches from useData/useNumRows hooks to direct context reads.
src/providers/ScrollProvider.tsx Uses ViewportHeightContext / TableCornerHeightContext / NumRowsContext directly.
src/providers/OrderByProvider.tsx Uses ExclusiveSortContext directly.
src/providers/ColumnWidthsProvider.tsx Uses ViewportWidthContext / TableCornerWidthContext / NumColumnsContext directly.
src/providers/ColumnParametersProvider.tsx Uses ColumnDescriptorsContext directly.
src/providers/CellNavigationProvider.tsx Uses NumRowsContext directly.
src/hooks/useFetchCells.ts Uses DataContext / NumRowsContext directly for fetch computations.
src/contexts/ViewportSizeContext.ts Removes wrapper hooks, leaving only contexts.
src/contexts/TableCornerSizeContext.ts Adds defaultTableCornerHeight, makes height context non-optional, removes wrapper hooks.
src/contexts/DataContext.ts Removes wrapper hooks (including useData), sets a non-throwing default DataContext value.
src/components/TableCorner/TableCorner.tsx Reads SetTableCornerSizeContext directly.
src/components/HighTable/Wrapper.tsx Reads NumRowsContext / TableCornerHeightContext directly.
src/components/HighTable/Slice.tsx Reads DataContext / DataVersionContext / NumRowsContext directly.
src/components/HighTable/Scroller.tsx Reads SetViewportSizeContext directly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/contexts/DataContext.ts Outdated
Comment thread test/providers/DataProvider.test.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/providers/DataProvider.test.tsx Outdated
Comment thread test/providers/TableCornerSizeProvider.test.tsx
@severo severo merged commit 89d5fb9 into master Mar 6, 2026
5 checks passed
@severo severo deleted the simplify branch March 6, 2026 09:12
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.

2 participants