Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-table/src/Subscribe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useStore } from '@tanstack/react-store'
import { shallow, useStore } from '@tanstack/react-store'
import type {
NoInfer,
RowData,
Expand Down Expand Up @@ -63,7 +63,7 @@ export function Subscribe<
>(
props: SubscribeProps<TFeatures, TData, TSelected>,
): ReturnType<FunctionComponent> {
const selected = useStore(props.table.store, props.selector)
const selected = useStore(props.table.store, props.selector, shallow)
Copy link
Member

Choose a reason for hiding this comment

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

thanks, this was needed.


return typeof props.children === 'function'
? props.children(selected)
Expand Down
23 changes: 12 additions & 11 deletions packages/react-table/src/useLegacyTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
sortFns,
stockFeatures,
} from '@tanstack/table-core'
import { useMemo } from 'react'
import { useStore } from '@tanstack/react-store'
import { useCallback, useMemo } from 'react'
import { shallow, useStore } from '@tanstack/react-store'
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove unused imports.

useCallback, shallow, and useStore are imported but not used in this file. These appear to be leftovers from the refactoring.

🧹 Proposed fix to remove unused imports
-import { useCallback, useMemo } from 'react'
-import { shallow, useStore } from '@tanstack/react-store'
+import { useMemo } from 'react'
📝 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 { useCallback, useMemo } from 'react'
import { shallow, useStore } from '@tanstack/react-store'
import { useMemo } from 'react'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-table/src/useLegacyTable.ts` around lines 18 - 19, The file
imports unused symbols—remove the unused imports useCallback, shallow, and
useStore from the import lines in useLegacyTable.ts; specifically delete
useCallback from the 'react' import and remove shallow and useStore from the
'@tanstack/react-store' import so only actually used exports remain, then run a
quick lint/type-check to confirm no references remain.

import { useTable } from './useTable'
import type {
Cell,
Expand Down Expand Up @@ -419,20 +419,21 @@ export function useLegacyTable<TData extends RowData>(
}

// Call useTable with the v9 API, subscribing to all state changes
const table = useTable<StockFeatures, TData, TableState<StockFeatures>>({
...restOptions,
_features: stockFeatures,
_rowModels,
} as TableOptions<StockFeatures, TData>)

const state = useStore(table.store, (state) => state)
const table = useTable<StockFeatures, TData, TableState<StockFeatures>>(
{
...restOptions,
_features: stockFeatures,
_rowModels,
} as TableOptions<StockFeatures, TData>,
(state) => state,
)

return useMemo(
() =>
({
...table,
getState: () => state,
getState: () => table.state,
}) as LegacyReactTable<TData>,
[table, state],
[table],
Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to remember why I even did had a dedicated useStore call here, I think it might have had something to do with the react compiler. I'm fine shipping this though

Copy link
Collaborator Author

@riccardoperra riccardoperra Mar 12, 2026

Choose a reason for hiding this comment

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

mmh could it be because previously there were some updates done in useEffect with queueMicrotask to update the baseStore? That's something we removed after state store updates automatically when options changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Anyway, I just tested the useLegacyTable example with this configuration and it seems working the same

 react({
      babel: {
        plugins: ['babel-plugin-react-compiler'],
      },
    }),

)
}
Loading