% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hooks.R
\name{useFetcher}
\alias{useFetcher}
\title{useFetcher}
\usage{
useFetcher(
  into = NULL,
  as = "children",
  selector = "state",
  render = NULL,
  fetcherKey = NULL,
  ...
)
}
\arguments{
\item{into}{A component (HTML tag or \pkg{shiny.react}-based element)
that will receive the hook data as the specified prop.}

\item{as}{Character. The name of the component's prop to inject the hook
data into (by default \code{"children"} for text display, \code{"rows"} for
a data grid, \code{"value"} for an input).}

\item{selector}{Character. Optional key to extract from the hook data object.
If \code{NULL} (the default), the entire data is passed. Dotted paths
like \code{"summary.title"} navigate nested objects.}

\item{render}{Optional \code{\link{JS}} function \code{(value) => ReactNode}
used in place of \code{into}/\code{as}. Mirrors the native React Router
pattern for cases where a single prop is not expressive enough (e.g.
\code{JS("v => `${v.first} ${v.last}`")}).}

\item{fetcherKey}{Character. Optional key to share a fetcher across
components (e.g. \code{"my-fetcher"}).}

\item{...}{Additional props to pass to the component.}
}
\description{
\url{https://api.reactrouter.com/v7/functions/react-router.useFetcher.html}
}
\details{
Calls the \code{useFetcher()} hook and injects the result (or a
\code{selector} from it) \code{as} a prop of the \code{into} component.
Use to fetch data or submit forms without causing a navigation.
The fetcher object has \code{state} (\code{"idle"}/\code{"loading"}/\code{"submitting"}) and
\code{data} (the response from a loader or action).


\code{selector} defaults to \code{"state"} so the default \code{into}/
\code{children} display shows a readable string (\code{"idle"} /
\code{"loading"} / \code{"submitting"}). The full fetcher object contains
methods (\code{submit}, \code{load}, \code{Form}) that would be silently
dropped by JSON serialization if the whole object were rendered as
children. To call those methods, use the \code{render = JS(...)} form,
which receives the full fetcher: \code{render = JS("f => <button onClick={() => f.load('/data')}>Reload</button>")}.
}
