useParams
The params of the route (and its ancestors), as a view with one memo per key: a reader of one key does not rerun when another key changes.
The params of the route (and its ancestors), as a view with one memo per key: a reader of one key does not rerun when another key changes. Read it inside a component or an effect.
Import#
ts
import { useParams } from "@shadow-js/router";
Signature#
ts
function useParams<P extends RegisteredPath = RegisteredPath>(
options: FromOptions<P> = {},
): ParamsView<P>
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 params, typed by from when paths are registered.
Examples#
ts
const params = useParams({ from: "/posts/:id" });
insert(el, () => `Post ${params.id}`);