Button with transition

    0

    1

    Jose Romero

    Remix TypeScript public recipes

    This code creates a button that will submit the form when it is clicked. The code first uses the useTransition() function to determine the transition between the 'submitting' and 'loading' states. The SubmitButton() function then sets the text of the button to either "Saving..." or "Saved!", depending on the state of the transition.

    Library: remix

    Shortcut: remix.button.transition

    import { useTransition } from "remix";
    
    function filename() {
      const transition = useTransition();
      const text =
        transition.state === "submitting"
          ? "Saving..."
          : transition.state === "loading"
          ? "Saved!"
          : "Go";
      return <button type="submit">{text}</button>;
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.