useFormAction
useFormAction
.
Resolves the value of a <form action>
attribute using React Router's relative paths. This can be useful when computing the correct action for a <button formAction>
, for example, when a <button>
changes the action of its <form>
.
function SomeComponent() {
return (
<button
formAction={useFormAction("destroy")}
formMethod="post"
>
Delete
</button>
);
}
(Yes, HTML buttons can change the action of their form!)
useFormAction
docs.