| useSearchParams | R Documentation |
https://api.reactrouter.com/v7/functions/react-router.useSearchParams.html
useSearchParams(into = NULL, as = "children", param = NULL, render = NULL, ...)
into |
A component (HTML tag or shiny.react-based element) that will receive the hook data as the specified prop. |
as |
Character. The name of the component's prop to inject the hook
data into (by default |
param |
Character. Name of a single query parameter to extract.
Returns a character vector of all values for that key (length 0 if
absent, length 1+ otherwise). When Empty vs. missing. A missing key produces a length-0 vector,
which renders as an empty string when injected with the default
|
render |
Optional |
... |
Additional props to pass to the component. |
Calls the useSearchParams() hook and injects the result
as a prop of the into component. Use the param
argument to extract a query parameter by name.
Values are always returned as character vectors so that repeated keys
(e.g. "?tag=a&tag=b") are preserved. When injected as
"children", vectors are joined with ", "; for custom
formatting, use render.
Reading vs. writing. The upstream JS hook returns a tuple
[searchParams, setSearchParams]. This wrapper splits the two paths:
into / as — read-only. Receives the parsed
params (or one param) and ignores the setter.
render — receives both as (params, setSearchParams),
so use this form when you need to update the URL programmatically:
useSearchParams(render = JS(
"(p, set) => <button onClick={() => set({tag:'b'})}>Filter</button>"
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.