% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hooks.R
\name{useSubmit}
\alias{useSubmit}
\title{useSubmit}
\usage{
useSubmit(into = NULL, as = "children", render = 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{...}{Additional props to pass to the component.}
}
\description{
\url{https://api.reactrouter.com/v7/functions/react-router.useSubmit.html}
}
\details{
Calls the \code{useSubmit()} hook and passes the submit function to
\code{render} (or injects it \code{as} a prop of \code{into}).
The submit function has signature \code{submit(target, options?)} and
triggers a form submission (including calling the route's \code{action})
without requiring a \code{\link{Form}} element.
Only works inside a data router.

Because the hook returns a function (not a value), the \code{into} form
is rarely useful here -- prefer \code{render = JS(...)} so you can call
the submit function from inside the rendered element.
}
\examples{
\dontrun{
useSubmit(render = JS(
  "submit => <button onClick={() =>
     submit({ intent: 'delete' }, { method: 'post' })
   }>Delete</button>"
))
}

}
