Skip to content

Add preact integration for tanstack-table#6173

Open
JoviDeCroock wants to merge 1 commit intoTanStack:mainfrom
JoviDeCroock:add-preact-integration
Open

Add preact integration for tanstack-table#6173
JoviDeCroock wants to merge 1 commit intoTanStack:mainfrom
JoviDeCroock:add-preact-integration

Conversation

@JoviDeCroock
Copy link

@JoviDeCroock JoviDeCroock commented Feb 15, 2026

🎯 Changes

  • Added a new @tanstack/preact-table adapter package aligned with existing framework integrations.
  • Implemented usePreactTable and flexRender with @tanstack/table-core re-exports.
  • Wired docs/navigation for Preact (README, install docs, framework pages, and docs config).
  • Added a preact ignore in test:sherif and updated lockfile.

Summary by CodeRabbit

  • New Features

    • Added official Preact framework support to TanStack Table
    • Introduced usePreactTable hook for seamless Preact integration
    • New flexRender utility for rendering Preact components and values
  • Documentation

    • Added comprehensive Preact integration guides covering table state management and setup
    • Updated framework overview and installation documentation to include Preact

@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2026

⚠️ No Changeset found

Latest commit: 9d2a6f0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Adds a new Preact integration package to TanStack Table with complete setup including source code, build configuration, and tests. Updates documentation and configuration files to reference the new Preact adapter alongside existing frameworks.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, docs/introduction.md, docs/overview.md, docs/guide/tables.md, docs/installation.md, docs/framework/preact/preact-table.md, docs/framework/preact/guide/table-state.md
Multiple documentation files updated to include Preact in framework lists, installation instructions, and new guides for Preact-specific table usage and state management.
Documentation Configuration
docs/config.json
Added navigation entries for Preact Table Adapter and Table State guide under framework and core guides sections.
Build and Test Scripts
package.json
Updated test:sherif script to include preact (-i preact) in the framework test run.
New Preact Table Package - Core
packages/preact-table/src/index.ts
Implements usePreactTable hook for Preact integration, Renderable type alias, flexRender helper function, and isComponent utility for component detection.
New Preact Table Package - Configuration
packages/preact-table/package.json, packages/preact-table/rollup.config.mjs, packages/preact-table/tsconfig.json, packages/preact-table/vitest.config.ts
Package manifest, build configuration, TypeScript, and test runner setup for the new Preact table adapter.
New Preact Table Package - Tests
packages/preact-table/tests/core/core.test.tsx, packages/preact-table/tests/test-setup.ts
Test suite covering flexRender behavior, table instance stability, and state update propagation via onStateChange callback.

Sequence Diagram(s)

sequenceDiagram
    participant Component as Preact Component
    participant Hook as usePreactTable Hook
    participant State as Internal State
    participant TableCore as Table Core
    participant Callback as User Callbacks

    Component->>Hook: Call usePreactTable(options)
    Hook->>State: Initialize/Update state
    Hook->>TableCore: createTable<TData>(mergedOptions)
    TableCore->>Hook: Return table instance
    Hook->>Hook: Store table in ref
    
    Note over Component,Hook: Component renders with table
    
    Component->>Hook: User triggers state change (e.g., sort)
    Hook->>State: Update internal state
    Hook->>Callback: Call onStateChange if provided
    Callback->>Hook: Return merged state
    Hook->>TableCore: Update table options
    Hook->>Component: Return updated table instance
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • KevinVandy

Poem

🐰 Hops through the code with leafy cheer,
Preact joins the table sphere!
usePreactTable's rendered so fine,
State flows smooth, like garden twine. 🥬✨

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the key changes (adapter package, implementation, docs, test config) but lacks the required checklist items and changeset information per the template. Add the unchecked checklist items and confirm whether a changeset was generated, as this affects published code.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add preact integration for tanstack-table' accurately summarizes the main change: adding a new Preact adapter package with implementation and documentation.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@docs/framework/preact/guide/table-state.md`:
- Around line 188-195: The example incorrectly types the state as
useState<SortingState[]> which produces a nested array; change the state to
useState<SortingState> so sorting is a single SortingState (alias for
ColumnSort[]). Update the variable declaration using SortingState (and keep
setSorting signature) in the example where usePreactTable and useState are used
so autocomplete and types work correctly for sorting.id and sorting.desc.
- Line 96: The sentence contains a stray trailing backtick after "state"; update
the prose so the mention of the column sizing state is correctly formatted
(e.g., `columnSizingInfo` state) by removing the extra backtick; this change
applies near the mention of the onStateChange table option and the symbol
columnSizingInfo in the documentation.

In `@packages/preact-table/tests/core/core.test.tsx`:
- Around line 89-99: The test "keeps a stable table instance across re-renders"
currently uses expect(prev).toStrictEqual(next) which checks structural equality
not referential identity; update the assertion using the tableRef variables to
expect(prev).toBe(next) so the test verifies the exact same object reference is
preserved across re-renders (keep the existing prev/next setup and act() block,
just replace the toStrictEqual assertion).
🧹 Nitpick comments (1)
packages/preact-table/tests/core/core.test.tsx (1)

38-42: Consider extracting a shared afterEach cleanup instead of manual teardown in every test.

Each test manually renders null and removes the container. A shared afterEach (or a helper that returns a cleanup function) would reduce boilerplate and guard against forgotten teardown if more tests are added.


#### Fully Controlled State

Alternatively, you can control the entire table state with the `onStateChange` table option. It will hoist out the entire table state into your own state management system. Be careful with this approach, as you might find that raising some frequently changing state values up a preact tree, like `columnSizingInfo` state`, might cause bad performance issues.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo: stray backtick in prose.

There's a mismatched backtick: `columnSizingInfo` state` — the trailing backtick after "state" is erroneous.

Proposed fix
-A couple of more tricks may be needed to make this work. If you use the `onStateChange` table option, the initial values of the `state` must be populated with all of the relevant state values for all of the features that you want to use. You can either manually type out all of the initial state values, or use the `table.setOptions` API in a special way as shown below.
+raising some frequently changing state values up a preact tree, like `columnSizingInfo` state, might cause bad performance issues.

More precisely, on line 96 fix:

-like `columnSizingInfo` state`, might cause bad performance issues.
+like `columnSizingInfo` state, might cause bad performance issues.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Alternatively, you can control the entire table state with the `onStateChange` table option. It will hoist out the entire table state into your own state management system. Be careful with this approach, as you might find that raising some frequently changing state values up a preact tree, like `columnSizingInfo` state`, might cause bad performance issues.
Alternatively, you can control the entire table state with the `onStateChange` table option. It will hoist out the entire table state into your own state management system. Be careful with this approach, as you might find that raising some frequently changing state values up a preact tree, like `columnSizingInfo` state, might cause bad performance issues.
🧰 Tools
🪛 LanguageTool

[grammar] ~96-~96: Ensure spelling is correct
Context: ...e frequently changing state values up a preact tree, like columnSizingInfo state`, m...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/framework/preact/guide/table-state.md` at line 96, The sentence contains
a stray trailing backtick after "state"; update the prose so the mention of the
column sizing state is correctly formatted (e.g., `columnSizingInfo` state) by
removing the extra backtick; this change applies near the mention of the
onStateChange table option and the symbol columnSizingInfo in the documentation.

Comment on lines +188 to +195
import { usePreactTable, type SortingState } from '@tanstack/preact-table'
//...
const [sorting, setSorting] = useState<SortingState[]>([
{
id: 'age', //you should get autocomplete for the `id` and `desc` properties
desc: true,
}
])
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Incorrect type usage: SortingState[] should be SortingState.

SortingState is already defined as ColumnSort[] in table-core. Writing useState<SortingState[]> creates a ColumnSort[][] (array of arrays), which is wrong and will cause type errors.

Proposed fix
-const [sorting, setSorting] = useState<SortingState[]>([
+const [sorting, setSorting] = useState<SortingState>([
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { usePreactTable, type SortingState } from '@tanstack/preact-table'
//...
const [sorting, setSorting] = useState<SortingState[]>([
{
id: 'age', //you should get autocomplete for the `id` and `desc` properties
desc: true,
}
])
import { usePreactTable, type SortingState } from '@tanstack/preact-table'
//...
const [sorting, setSorting] = useState<SortingState>([
{
id: 'age', //you should get autocomplete for the `id` and `desc` properties
desc: true,
}
])
🤖 Prompt for AI Agents
In `@docs/framework/preact/guide/table-state.md` around lines 188 - 195, The
example incorrectly types the state as useState<SortingState[]> which produces a
nested array; change the state to useState<SortingState> so sorting is a single
SortingState (alias for ColumnSort[]). Update the variable declaration using
SortingState (and keep setSorting signature) in the example where usePreactTable
and useState are used so autocomplete and types work correctly for sorting.id
and sorting.desc.

Comment on lines +89 to +99
const prev = tableRef

act(() => {
triggerRerender?.()
})

const next = tableRef

expect(prev).toBeDefined()
expect(next).toBeDefined()
expect(prev).toStrictEqual(next)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

toStrictEqual does not verify referential identity — use toBe instead.

The test is named "keeps a stable table instance across re-renders", which implies the same object reference is returned. toStrictEqual only checks deep structural equality, so two different objects with the same shape would also pass. Use toBe for reference equality.

Proposed fix
-    expect(prev).toStrictEqual(next)
+    expect(prev).toBe(next)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const prev = tableRef
act(() => {
triggerRerender?.()
})
const next = tableRef
expect(prev).toBeDefined()
expect(next).toBeDefined()
expect(prev).toStrictEqual(next)
const prev = tableRef
act(() => {
triggerRerender?.()
})
const next = tableRef
expect(prev).toBeDefined()
expect(next).toBeDefined()
expect(prev).toBe(next)
🤖 Prompt for AI Agents
In `@packages/preact-table/tests/core/core.test.tsx` around lines 89 - 99, The
test "keeps a stable table instance across re-renders" currently uses
expect(prev).toStrictEqual(next) which checks structural equality not
referential identity; update the assertion using the tableRef variables to
expect(prev).toBe(next) so the test verifies the exact same object reference is
preserved across re-renders (keep the existing prev/next setup and act() block,
just replace the toStrictEqual assertion).

@KevinVandy
Copy link
Member

@JoviDeCroock Thanks for working on this. We already have a preact adapter in the alpha v9 branch following better state patterns with TanStack Preact Store. Maybe we will still release this for backwards compat for v8 though.

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