import { useForm } from 'react-hook-form';
      const { register, handleSubmit, watch, control } = useForm(); 
      Javascript language logo
      your recipe card header background

      React form useForm hook

      React JavaScript Recipes

      register(form, "example"); handleSubmit(register); watch(register, "submit"); control(register, "submit", { message: "Your input has been submitted!" });

      register stores the reference to the form object.

      handleSubmit is called when the user submits the form. It registers a function to be called when the submit event is triggered.

      watch is used to keep an eye on the register object and trigger the function registered when the submit event is triggered, based on the value of the register field.

      control is used to bind the register field to a function that can be called to handle the submission of the form. In this case, the function will print out a message stating that the user's input has been submitted.

      Library: react

      Shortcut: react.form.hook.use


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.