useSearch
The validated search of the route, as a view with one memo per key.
The validated search of the route, as a view with one memo per key. Changing ?page does not
rerun a reader of ?tab.
Import#
ts
import { useSearch } from "@shadow-js/router";
Signature#
ts
function useSearch<S extends object = Readonly<SearchRecord>>(
options: { readonly from?: RegisteredPath } = {},
): S
Parameters#
| Name | Description |
|---|---|
options |
from names the route. Without it, the route is the one rendering the component. |
Returns#
A read-only view of the search. Typed as S (the route's validator type) when given.
Examples#
ts
const search = useSearch<{ page: number }>({ from: "/posts" });