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

\item{as}{Character. The name of the component's prop to inject the hook
value into. Defaults to \code{"children"}.}

\item{render}{Optional \code{\link{JS}} function \code{(value) => ReactNode}
used in place of \code{into}/\code{as}.}

\item{context}{Optional value to expose to descendants via
\code{\link{useOutletContext}}.}

\item{...}{Additional props to pass to the component.}
}
\description{
\url{https://api.reactrouter.com/v7/functions/react-router.useOutlet.html}
}
\details{
Calls the \code{useOutlet()} hook and injects the matched child route's
element \code{as} a prop of the \code{into} component (or passes it to
\code{render}). Returns \code{NULL} when no child route matches -- useful for
rendering a fallback inside a layout when the user is on the parent route.

Differs from the \code{\link{Outlet}} component in that it returns the
element as a value, so you can branch on whether a child route is matched.
}
\examples{
\dontrun{
# In a layout route: render the matched child, or a fallback if on the
# parent route itself.
useOutlet(
  render = JS("o => o || <p>Pick a section from the menu.</p>")
)

# Inject the matched outlet element as the body of a wrapping <section>.
useOutlet(into = shiny::tags$section(class = "page"))
}

}
