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>.

  1. function SomeComponent() {
  2. return (
  3. <button
  4. formAction={useFormAction("destroy")}
  5. formMethod="post"
  6. >
  7. Delete
  8. </button>
  9. );
  10. }

(Yes, HTML buttons can change the action of their form!)

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