useNavigation

This hook is simply a re-export of React Router useNavigation.

  1. import { useNavigation } from "@remix-run/react";
  2. function SomeComponent() {
  3. const navigation = useNavigation();
  4. navigation.state; // "idle" | "submitting" | "loading"
  5. navigation.location; // Location being navigated to
  6. navigation.formData; // formData being submitted
  7. navigation.formAction; // url being submitted to
  8. navigation.formMethod; // "GET" | "POST" | "PATCH" | "PUT" | "DELETE"
  9. }

The useNavigation().formMethod field is lowercase without the future.v2_normalizeFormMethod Future Flag. This is being normalized to uppercase to align with the fetch() behavior in v2, so please upgrade your Remix v1 applications to adopt the uppercase HTTP methods.

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