Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useFormik

import React from 'react';
2 import { useFormik } from 'formik';
3 
4 const SignupForm = () => {
5   const formik = useFormik({
6     initialValues: {
7       firstName: '',
8       lastName: '',
9       email: '',
10     },
11     onSubmit: values => {
12       alert(JSON.stringify(values, null, 2));
13     },
14   });
15   return (
16     <form onSubmit={formik.handleSubmit}>
17       <label htmlFor="firstName">First Name</label>
18       <input
19         id="firstName"
20         name="firstName"
21         type="text"
22         onChange={formik.handleChange}
23         value={formik.values.firstName}
24       />
25       <label htmlFor="lastName">Last Name</label>
26       <input
27         id="lastName"
28         name="lastName"
29         type="text"
30         onChange={formik.handleChange}
31         value={formik.values.lastName}
32       />
33       <label htmlFor="email">Email Address</label>
34       <input
35         id="email"
36         name="email"
37         type="email"
38         onChange={formik.handleChange}
39         value={formik.values.email}
40       />
41       <button type="submit">Submit</button>
42     </form>
43   );
44 };
Comment

PREVIOUS NEXT
Code Example
Javascript :: load external javascript from console 
Javascript :: ngif is string angular 
Javascript :: ssg full form in nextjs 
Javascript :: How to upload an Excel sheet file using react.js and display data to a table 
Javascript :: webpack build watch 
Javascript :: react cdn 
Javascript :: javascript var,let,const compare 
Javascript :: capitalize name function javascript 
Javascript :: how to change port in react js 
Javascript :: get all child element of class javascript 
Javascript :: how to create react native app 
Javascript :: dynamic button click in javascript 
Javascript :: scrollintoview javascript 
Javascript :: react router dom v6 
Javascript :: redux mapstatetoprops get props 
Javascript :: react router link with params 
Javascript :: js find all custom window properties 
Javascript :: new line in rdlc expression 
Javascript :: pm2 config changes update environments 
Javascript :: onchange on multiple ids jquery 
Javascript :: js convert array to object 
Javascript :: javascript change select element 
Javascript :: how draw table from json ajax 
Javascript :: curl send json as variable 
Javascript :: discord.js get server guild id 
Javascript :: SHOPIFY LANGUAGE SELECTOR 
Javascript :: input from terminal node js 
Javascript :: useEffect in nextjs 
Javascript :: download pdf javascript 
Javascript :: class javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =