API/useReactRouterAdapter()
useReactRouterAdapter()
hooksrc/hooks/use-react-router-adapter.ts1 parameter
React Router as a RouterAdapter: its location in, its navigate out.
Call it inside a React Router tree — declarative, data or framework mode. Pass the result to
useQubeeList for one list, or wrap the routes in ReactRouterAdapter and every
list below finds it.
A list navigation keeps the scroll position: where the app renders <ScrollRestoration>, React
Router would otherwise scroll to the top each time a filter or a page number changes.
Import
Section titled “Import”import { useReactRouterAdapter } from '@qubeejs/react/react-router';Signature
Section titled “Signature”function useReactRouterAdapter(options: ReactRouterAdapterOptions): RouterAdapterParameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
ReactRouterAdapterOptions |
scroll: let React Router reset the scroll position; false by default |
Returns
Section titled “Returns”The current pathname and query, and a navigate that goes through React Router
Example
Section titled “Example”function Articles(): ReactElement { const list = useQubeeList(articleList, useReactRouterAdapter());
return <Link to={list.href({ page: 2 })}>2</Link>;}