Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

npm react hook form

npm i react-hook-form
Comment

react form hook npm

yarn add react-hook-form
Comment

npm hook form

import React from 'react';import { useForm } from 'react-hook-form'; function App() {  const { register, handleSubmit, errors } = useForm(); // initialise the hook  const onSubmit = (data) => {    console.log(data);  };   return (    <form onSubmit={handleSubmit(onSubmit)}>      <input name="firstname" ref={register} /> {/* register an input */}            <input name="lastname" ref={register({ required: true })} />      {errors.lastname && 'Last name is required.'}            <input name="age" ref={register({ pattern: /d+/ })} />      {errors.age && 'Please enter number for age.'}            <input type="submit" />    </form>  );}
Comment

react-hook-form-input npm

$ npm install react-hook-form-input
Comment

react-hook-form-input npm

import React from 'react';import useForm from 'react-hook-form';import { RHFInput } from 'react-hook-form-input';import Select from 'react-select'; const options = [  { value: 'chocolate', label: 'Chocolate' },  { value: 'strawberry', label: 'Strawberry' },]; function App() {  const { handleSubmit, register, setValue, reset } = useForm();   return (    <form onSubmit={handleSubmit(data => console.log(data))}>      <RHFInput        as={<Select options={options} />}        rules={{ required: true }}        name="reactSelect"        register={register}        setValue={setValue}      />      <button type="button">        Reset Form      </button>      <button>submit</button>    </form>  );}
Comment

PREVIOUS NEXT
Code Example
Javascript :: mongoose array includes 
Javascript :: jsoup 
Javascript :: create a reactjs app with backend and docker 
Javascript :: javascript remove an element from an array 
Javascript :: react native generate signed apk getting older version 
Javascript :: delegate in javascript 
Javascript :: why we use $ in jquery 
Javascript :: working of a recursive function 
Javascript :: jetty 
Javascript :: how to detect a section is visible in jquery 
Javascript :: javascript number() method 
Javascript :: input type for mobile number in react js 
Javascript :: default function parameters javascript 
Javascript :: javascript callbacks 
Javascript :: javaScript Math.log() Method 
Javascript :: axios remove existing token 
Javascript :: call node.js file electron 
Javascript :: how to create variables using javascript 
Javascript :: buttons js before submit 
Javascript :: Hint:“javascript sleep 1 second” is a pretty common code problem that people search ;-) 
Javascript :: how to see javascript code in chrome 
Javascript :: dynamodb async await 
Javascript :: javascript array loop back 
Javascript :: emit event to a single socket id in socket 
Javascript :: javascript make pong 
Javascript :: jquery-3.5.1.min.js download 
Python :: django EMAIL_BACKEND console 
Python :: python subtract months from date 
Python :: Import "reportlab" could not be resolved django 
Python :: get terminal size python 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =