| dataResponse | R Documentation |
https://api.reactrouter.com/v7/functions/react-router.data.html
dataResponse(value, init = NULL)
value |
The payload to expose via |
init |
Optional. Either a list with |
Returns a JS loader function that resolves to a React Router
data() response – a thin wrapper that lets you attach an HTTP
status, statusText, and/or headers alongside the
loader/action payload while still exposing value via
useLoaderData / useActionData.
Use the R helper for static loaders that always return the same value plus
status. For values computed inside a custom loader/action, call
window.jsmodule['@/reactRouter'].helpers.data(value, init) directly
in your JS() string, e.g.
loader = JS("async () => {
const { data } = window.jsmodule['@/reactRouter'].helpers;
const rows = await fetchRows();
return data({ rows }, { status: 200 });
}")
A JS expression suitable for the loader or
action argument of Route.
## Not run:
Route(
path = "/profile",
loader = dataResponse(
list(name = "Ada", role = "Engineer"),
init = list(status = 200)
),
element = useLoaderData(tags$pre())
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.