React Router API Reference
    Preparing search index...

    Function useFormAction

    • Resolves the URL to the closest route in the component hierarchy instead of the current URL of the app.

      This is used internally by Form to resolve the action to the closest route, but can be used generically as well.

      Parameters

      • Optionalaction: string

        The action to append to the closest route URL. Defaults to the closest route URL.

      • options: { relative?: RelativeRoutingType } = {}

        Options

        • Optionalrelative?: RelativeRoutingType

          The relative routing type to use when resolving the action. Defaults to "route".

      Returns string

      The resolved action URL.

      import { useFormAction } from "react-router";

      function SomeComponent() {
      // closest route URL
      let action = useFormAction();

      // closest route URL + "destroy"
      let destroyAction = useFormAction("destroy");
      }

      @public

      framework

      data