Skip to content

support onStateChange#595

Merged
taro-28 merged 1 commit intomainfrom
feat/onStateChange-encoder-support
Sep 6, 2025
Merged

support onStateChange#595
taro-28 merged 1 commit intomainfrom
feat/onStateChange-encoder-support

Conversation

@taro-28
Copy link
Copy Markdown
Owner

@taro-28 taro-28 commented Sep 2, 2025

What

Supports onStateChange.

This change ensures that the table state is synchronized with URL parameters even when table.setState() or table.reset() is executed.

Usage

Since onStateChange has been added to the return value of useTableSearchParams, you can simply set it in useReactTable.

const router = useRouter();

// `onStateChange` is added into `stateAndOnChanges`!
const stateAndOnChanges = useTableSearchParams(router);

const table = useReactTable({
  ...stateAndOnChanges,
  data,
  columns,
  getCoreRowModel: getCoreRowModel(),
  // ...
});

const handleXXX = () => {
  table.reset();
  // or
  table.setState({
    globalFilter: "",
    sorting: [],
  });
};

Related Issue

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tanstack-table-search-params-next-app-router Ready Ready Preview Comment Sep 6, 2025 2:52am
tanstack-table-search-params-next-pages-router Ready Ready Preview Comment Sep 6, 2025 2:52am

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Sep 2, 2025

Deploying tanstack-table-search-params-tanstack-router with  Cloudflare Pages  Cloudflare Pages

Latest commit: 340395b
Status: ✅  Deploy successful!
Preview URL: https://22c9ce91.tanstack-table-search-params-tanstack-router.pages.dev
Branch Preview URL: https://feat-onstatechange-encoder-s.tanstack-table-search-params-tanstack-router.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Sep 2, 2025

Deploying tanstack-table-search-params-react-router-lib with  Cloudflare Pages  Cloudflare Pages

Latest commit: 340395b
Status: ✅  Deploy successful!
Preview URL: https://392acef9.tanstack-table-search-params-react-router-lib.pages.dev
Branch Preview URL: https://feat-onstatechange-encoder-s.tanstack-table-search-params-react-router-lib.pages.dev

View logs

@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from dda3365 to 295645f Compare September 2, 2025 21:35
@taro-28 taro-28 changed the title feat: add encoder support for onStateChange feat: add support for onStateChange Sep 2, 2025
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from 295645f to 205ff04 Compare September 3, 2025 12:43
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from 205ff04 to 265a2fc Compare September 3, 2025 12:44
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from 265a2fc to b2306ee Compare September 3, 2025 12:57
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from b2306ee to ce861cc Compare September 6, 2025 02:40
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from ce861cc to 56c32fa Compare September 6, 2025 02:41
…ter options

Introduce a new test suite for the useTableSearchParams hook, focusing on various configurations of the globalFilter parameter. The tests cover scenarios including default values, custom encoders/decoders, and debounce settings, ensuring robust validation of state management and query parameter encoding.

Changes:
- Create onStateChange.test.ts with multiple test cases for globalFilter options
- Validate initial state, state updates, and reset behavior across different configurations
@taro-28 taro-28 force-pushed the feat/onStateChange-encoder-support branch from 56c32fa to 340395b Compare September 6, 2025 02:50
@taro-28 taro-28 changed the title feat: add support for onStateChange feat: onStateChange support Sep 6, 2025
@taro-28 taro-28 changed the title feat: onStateChange support support onStateChange Sep 6, 2025
@taro-28 taro-28 self-assigned this Sep 6, 2025
@taro-28 taro-28 marked this pull request as ready for review September 6, 2025 03:10
@taro-28 taro-28 merged commit 100776a into main Sep 6, 2025
9 checks passed
@taro-28 taro-28 deleted the feat/onStateChange-encoder-support branch September 6, 2025 03:10
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.

1 participant