Skip to content
API/useReactRouterAdapter()

useReactRouterAdapter()

hook
src/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 { useReactRouterAdapter } from '@qubeejs/react/react-router';
function useReactRouterAdapter(options: ReactRouterAdapterOptions): RouterAdapter
Parameter Type Description
options ReactRouterAdapterOptions scroll: let React Router reset the scroll position; false by default

The current pathname and query, and a navigate that goes through React Router

function Articles(): ReactElement {
const list = useQubeeList(articleList, useReactRouterAdapter());
return <Link to={list.href({ page: 2 })}>2</Link>;
}

ReactRouterAdapterOptions · RouterAdapter