Viewing docs for an older release. View latest

useFormAction

This hook is simply a re-export of React Router's 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!)

For more information and usage, please refer to the React Router useFormAction docs.

Docs and examples licensed under MIT