useTanStackRouterAdapter()
hookTanStack Router as a RouterAdapter: its location in, its navigate out.
It reads the query string as TanStack Router serialised it and navigates with whole hrefs, so
a basepath or a rewrite is honoured. The router’s search serialisers run in both directions:
its default pair re-types JSON-looking values (1.50 becomes 1.5, 10 becomes 10), and
the list settles on what the router wrote. Call it inside a TanStack Router tree. Pass the
result to useQubeeList for one list, or wrap the routes in
TanStackRouterAdapter and every list below finds it.
A list navigation keeps the scroll position: TanStack Router would otherwise scroll to the top each time a filter or a page number changes.
Import
Section titled “Import”import { useTanStackRouterAdapter } from '@qubeejs/react/tanstack-router';Signature
Section titled “Signature”function useTanStackRouterAdapter(options: TanStackRouterAdapterOptions): RouterAdapterParameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
TanStackRouterAdapterOptions |
scroll: scroll to the top on navigation; false by default |
Returns
Section titled “Returns”The current pathname and query, and a navigate that goes through TanStack Router
Example
Section titled “Example”function Articles(): ReactElement { const list = useQubeeList(articleList, useTanStackRouterAdapter());
return <button onClick={() => list.setPage(2)}>2</button>;}