showing results for - "react hooks form"
Oskar
26 Feb 2019
1import React from "react";
2import { useForm, Controller } from "react-hook-form";
3import Select from "react-select";
4import Input from "@material-ui/core/Input";
5import { Input as InputField } from "antd";
6
7export default function App() {
8  const { control, handleSubmit } = useForm();
9  const onSubmit = data => console.log(data);
10
11  return (
12    <form onSubmit={handleSubmit(onSubmit)}>
13      <Controller as={Input} name="HelloWorld" control={control} defaultValue="" />
14      <Controller as={InputField} name="AntdInput" control={control} defaultValue="" />
15      <Controller
16        as={Select}
17        name="reactSelect"
18        control={control}
19        onChange={([selected]) => {
20          // React Select return object instead of value for selection
21          return { value: selected };
22        }}
23        defaultValue={{}}
24      />
25
26      <input type="submit" />
27    </form>
28  );
29}
30
Keith
11 Mar 2016
1import React, { useState } from "react";
2import Checkbox from "@material-ui/core/Checkbox";
3import Button from "@material-ui/core/Button";
4import TextField from "@material-ui/core/TextField";
5import FormControlLabel from "@material-ui/core/FormControlLabel";
6import Typography from "@material-ui/core/Typography";
7import { makeStyles } from "@material-ui/core/styles";
8import Container from "@material-ui/core/Container";
9import { useForm } from "react-hook-form";
10import Rating from "@material-ui/lab/Rating";
11import StarBorderIcon from '@material-ui/icons/StarBorder';
12
13const useStyles = makeStyles((theme) => ({
14  paper: {
15    marginTop: theme.spacing(8),
16    display: "flex",
17    flexDirection: "column",
18    alignItems: "center"
19  },
20  form: {
21    width: "100%", // Fix IE 11 issue.
22    marginTop: theme.spacing(1)
23  },
24  submit: {
25    margin: theme.spacing(3, 0, 2)
26  }
27}));
28
29export default function Create() {
30  const classes = useStyles();
31  const [rating, setRating] = useState(2);
32  const { register, handleSubmit } = useForm();
33  const onSubmit = (data) => {
34    console.log(data);
35  };
36
37  return (
38    <Container component="main" maxWidth="xs">
39      <div className={classes.paper}>
40        <Typography component="h1" variant="h5">
41          Form
42        </Typography>
43        <form
44          className={classes.form}
45          noValidate
46          onSubmit={handleSubmit(onSubmit)}
47        >
48          <TextField
49            variant="outlined"
50            margin="normal"
51            fullWidth
52            id="title"
53            label="Title"
54            name="title"
55            autoFocus
56            inputRef={register()}
57          />
58          <FormControlLabel
59            control={
60              <Checkbox
61                inputRef={register}
62                name="remember"
63                defaultValue={false}
64              />
65            }
66            label="remember"
67          />
68          <br />
69          <FormControlLabel
70            control={
71              <>
72                <input
73                  name="rating"
74                  type="number"
75                  value={rating}
76                  ref={register}
77                  hidden
78                  readOnly
79                />
80                <Rating
81                  name="rating"
82                  value={rating}
83                  precision={0.5}
84                  onChange={(_, value) => {
85                    setRating(value);
86                  }}
87                  icon={<StarBorderIcon fontSize="inherit" />}
88                />
89              </>
90            }
91            label="select rating"
92          />
93          <Button
94            type="submit"
95            fullWidth
96            variant="contained"
97            color="primary"
98            className={classes.submit}
99          >
100            Submit
101          </Button>
102        </form>
103      </div>
104    </Container>
105  );
106}
107
Denise
24 Jul 2017
1import React from 'react';
2import { useForm } from 'react-hook-form';
3
4function App() {
5  const { register, handleSubmit, errors } = useForm(); // initialize the hook
6  const onSubmit = (data) => {
7    console.log(data);
8  };
9
10  return (
11    <form onSubmit={handleSubmit(onSubmit)}>
12      <input name="firstname" ref={register} /> {/* register an input */}
13      <input name="lastname" ref={register({ required: true })} />
14      {errors.lastname && 'Last name is required.'}
15      <input name="age" ref={register({ pattern: /\d+/ })} />
16      {errors.age && 'Please enter number for age.'}
17      <input type="submit" />
18    </form>
19  );
20}
Jenna
18 Jan 2019
1import React from 'react';
2import { useForm } from 'react-hook-form';
3import "./App.css";
4
5type Profile = {
6  firstname: string
7  lastname: string
8  age: number
9}
10
11function App() {
12  const {register, handleSubmit, errors} = useForm<Profile>()
13
14  const onSubmit = handleSubmit((data) => {
15    alert(JSON.stringify(data))
16  })
17
18  return (
19    <main>
20    <form onSubmit={onSubmit}>
21      <div>
22        <label htmlFor="firstname">First Name</label>
23        <input ref={register({ required: true })} id="firstname" name="firstname" type="text"/>
24        {
25          errors.firstname && <div className="error">Enter your name</div>
26        }
27      </div>
28      <div>
29        <label htmlFor="lastname">Last Name</label>
30        <input ref={register({ required: true })} id="lastname" name="lastname" type="text"/>
31        {
32          errors.lastname && <div className="error">Enter your last name</div>
33        }
34      </div>
35      <div>
36        <label htmlFor="age">Age</label>
37        <input ref={register({ required: true })} id="age" name="age" type="text"/>
38        {
39          errors.age && <div className="error">Enter your age</div>
40        }
41      </div>
42      <button type="submit">Save</button>
43    </form>
44    </main>
45  );
46}
47
48export default App;
Christopher
16 Jan 2019
1import React from 'react';
2import ReactDOM from 'react-dom';
3import { connect } from "react-redux";
4import useForm from 'react-hook-form';
5
6function SampleForm() {
7  const { register, handleSubmit } = useForm();
8  const onSubmit = data => {
9    alert(JSON.stringify(data));
10  };
11
12  return (
13    <div className="App">
14      <form onSubmit={handleSubmit(onSubmit)}>
15        <div>
16          <label htmlFor="firstName">First Name</label>
17          <input name="firstName" placeholder="bill" ref={register} />
18        </div>
19
20        <div>
21          <label htmlFor="lastName">Last Name</label>
22          <input name="lastName" placeholder="luo" ref={register} />
23        </div>
24
25        <div>
26          <label htmlFor="email">Email</label>
27          <input name="email" placeholder="bluebill1049@hotmail.com" type="email" ref={register} />
28        </div>
29        <button type="submit">Submit</button>
30      </form>
31    </div>
32  );
33}
34
35class Sample extends Component {
36  constructor(props) {
37    super(props);
38  }
39
40  render() {
41    return <SampleForm />;
42  }
43}
44
45export default connect()(Sample);
46
47const rootElement = document.getElementById('root');
48ReactDOM.render(<Sample />, rootElement);
queries leading to this page
innerref react form hookscontroller material ui react hook formreact hook form with react material uireact hook form 5creact hook form componentsreact hook form useeffect stackoverflowwhat is react hooks formreact hook formreact hook formmreact hook form controllerusing form with react hookoption form in react hooksreact hook form material ui text fieldmaterial ui form hooksconst mycompoent react 3afc example to submit the hook form datahook form reacthooks and formsreact hook form typesuseform hookreact hook form require based on fieldselect option in react forms hookreact hook form typescript versionform hooks reactreact hook form yupresolver react js form in hoksreact hook form material ui joi validationreact native form hook examplereact form with hooks examplereact hook form select material ui example react hook form with react select material ui inputref useeffect register use form hookreact js form hooksreact form withot hooksrecat hook formreact hook form typescript errorsreact hook form in react jsredux hook formsreact typescript hook form yupreact formshow to use react hook form in reactreact hook form watch typescript errorreact hook form types installreact hook formdoc react hook formsreact hook form with material uireact hooks form validator material uireact select with react hook formreact form with react hooksreact hook formreact hook form set value reduxreact simple form hookreact hook example formuseform state react hook form typescriptreact hook form selectreact hook form useform syntaxreact hook form in componentsreact hook form component typescriptreact form exampletypes reack hook formnetflify 2b react hook formtypescript react hook formraect hook formreact hook handle submitcontrol react hook formreact hooks forms validtionmaterial ui react hook form version 7react hooks form comreact hook form textfield select muiuseform react hook formreact formreact form hookreact hook with hookform stack overflowreact useform hookinputref 3d 28register 29control react hook form controlreactjs hooks formreact hook form antd input textareamaterial ui react hook formreact native basic form hooksreact hook form without material uireact hook form smart form material uireact form onsubmit hooksuseform typescriptreact hook form example stack overflowhook for formsreact hook form validation react nativereact hook form 22react native 22form useform hook validation material ui textfield selectreact hook validate yup react hook form typescriptreact hook form email validatipnreact hook form material ui classnamereact hook form react nativereact hook form inreact hook form function typereact js stackoverflow rreact hook formreact hook form date inputsubmit form using react hooksgithub react hook form example using a json and validation using formikreact hook form sandboxreact hook form telephone validationreactjs form hooksreact hook form agereacct hook form controllerform with hooks reactinput creator react hook fotmreact hook formreact hook form selectreact use hooks formforms hooks reactforms and react hooksreact hook form githubuse react hook formreact hook form restreact hook form email validationreact hook form yup typescript material uireact hook form how to usereact hook form material ui validate react hook form useform typescriptreact hook form formatreact hook form on clickreact use hook formreact use formforms and validations with react hook formformmethods from react hook form tsreact hook form react native examplereact form hook submitrequired hook formreact hook form antd input textareaduseform 28 29use form hook reactinstall yup jsreact hook form npm i tsreact hook form stack overflowrecdt hook formmaterial ui picker react hook formreact hook form material ui yupreact state hooks formcinput react hook form react hook form with react nativereact hook form githubreact hook formform useform hooks validation material ui textfield selectmaterial ui form tutprial ract hooksform react hookreact hook form controller propsreact hook form and material ui examplereact hook form tsreact hook form reactmui textfield react hook formmaterial ui with react hook formreact hools formwhy use react hook formreact hook form select valuereactjs form with hooksreact form hooks stack over flowreact hook form is touchedblack react hooks fomrreact form using react hooksexample useform hookreact hook form with material ui textfieldforms using react hookhow to react hook formwrapper for react select in react hook formreact hook form website validationcontroller react hook form material uireact hook form with material ui examplereact react hook formhow to react hook form on non form element stack overflowform react hooks stackoverflowreact hook form controlled inputreact hook form validation typescriptreact hook form if validreact form hookreact hook form with react hookreact useform 28 29react hook forms selectreact hook form validatorreact handle form submit hooksusing react hook formreact hook formexample react hooks form reactmaterial ui and react hook form examplereact hook form typescript yupresolverselect import from useformuse form hook react native typescriptemail js with react hook form site 3astackoverflow comtextfield material ui react hook formreact js form example hooksnpm install react hook formfill react hook form on componentusing metarial ui react hook registartion form exampleureact hook formreact hook form docsreact hook form with typescriptreact hook form react native 2btypescriptuseform hook typescript react hook formreact hook form with select optionusewatch react hook form exampleform reactreact register formreact hooks useformform in reactreact hook form material ui set valuereact hook form providerreact form hooks stackoverflowtype react hook formgithub react hook form examplereact material ui basic formreact hook form typescript yupimport register react hook form typescriptreact hook form in react nativereact hook form material ui label cover the valuereact custom hook form stackoverflowreact hook form github starsreact hook form watch typescriptmaterial ui reach hook form 7react hook form native validationinputref react hook form meaningmaterial ui react hook formreact select react hook formreact hook fromreact hooks form data capturereact hook form ts exampleis react hook form work on divupdate react hook form with material uireact hook form ref in material uireact hook form material uireact hooks form validation examplevalidation with hooks in reactreac hook formsimport react hook formreact hook form 7 material uireact hook formreact hook form mui 5react native form hooks with schema exampleform using react hooksreact hooks form material uireact hook input validationreact hook form netreact hook form github comreact hooksformhooks form reactreact hook form form validationhandling complex form state using react hooksreact hook form control type typescriptuserform 28 29 reactreact hook form select registerreact hook form number format material uireact use forms hooksimple form in reactexport react formreact hook form register typescriptmaterial ui form component validation using react js hooks formreact hook form with react nativereact hook form is submittingimport react hook form typesget value of textarea react hooksusefrom in react nativaematerial ui pickers setup in react hook formreact hook form form website patternreact form hook github starsreact hook form getvalues typescriptreact hooks formssimple form using react hooksreact hook form registerform in react hooksreact hook form regester inputuseform in react hooksformik vs react hook form stackoverflowmaterial ui react hook form input number form hook reactreact hook form how to register a selecthow to use react hook form with material uiform in react hookreactn hook formusewatch react hook formreact useformreact hook form with uireack hook form validate 2 formmaterial ui react hook form inputreact hook form typescriptreact form hook validationreact hook form typescript installreact hook frmreact contact form hooksreact hook form exampleredux hook formreact hooks material ui formreact hookform githubreact hooks simple form validationreactjs hook formsuseform react exampleuseformin react gitnpm install react hook form in githubimport create useform 2areact hook form v7 controller example stackblitzreact natike hooks formreact state hook formreact hook form methods tsreact form validate react hook form textfieldcontroller mapping react hook formreact hook form use field array stackblitzmaterial ui and react hook formrequire for react hook form in react nativereact hook form sreact hook form useform yupresolverreact hook form useform schema hook formreact contact form useformwhat is react form hookhook react form validationrest react hook formselect react hook formhow to pass list of patter to react hook form stackoverflowreact form hook in functional component stack overflowreact hook form material ui validationuseform in reactwhy react hook formformdata react hook formmaterial ui form validation react functional component hooksreact hook form material ui valueasnumberreat hook formreact hook form with componentsreact hook form isreact hook form 2breact validate formreact hook form react jsreact hook form livehow many render the form by react hook form react hook form add and siplayreact hook form material ui examplehow to react hook form on non form element stackoverflowreact hook form native react hools formsreact hook form with material uireact hook form watch stack overflowform using hooksreact hooks form material ui helper textreact hook form material uireact hook form examplereact form using hooksreact form example hooksreact form validation hooksreact form without hooksreact submit form hooksreact hook form input validationreact validation formuseform reactjsmaterial ui pickers with controller react hook formreact hook form patternvalidation on react form with hooksimple react hook formmaterial ui select react hook form tutorialreactjs hook formform hook with reactjsreact hook form typescript react nativereact forms using hooksreact hook form using emailjs stack over flowreact hook form 2creact material ui form examplehook react forms githubreactjs form validationreact hook form interger validationreact hook form componentreact form in hookform hookshandlesubmit react js hook formreact hook form 27react form hooksreact hook forms material uiyup react hook formreact forms hooksreact hook form material uireact calendar ref react hook formhow to implement select with object in react hook formreact hook form api connect with reduxreact hook form typescript controllerform validation hooksreact hook form typescript yupresolverreact hook form start valuesreact hook form form pattern websitematerial ui react hook form textfieldreact hook form github likeform built using react hook formuse of react form hookintegrating with global state react hook fromsuse react form hookreact native form hooksreact native hook formmobile number valition react hook formreact hook form with yup examplereact hook form andt react use form errorshooks 2fforms in reactform submit hooksform hooks reactuseform reactreact forms hookreact form with hooksreact hook form material ui text inputhooks react formmui picker is missing in the 27default value 27 prop of either its controller 28https 3a 2f 2freact hook form com 2fapi 23controller 29 or useform 28https 3a 2f 2freact hook form com 2fapi 23useform 29react native hooks formsmaterial ui ref react hook formreact form hook in react native examplereact hook form typesreact hook forms and questions typesreact hooks with formreact hooks remplatereact hook form react selecttreact native hooks form validationtouched fields will display react hook formreact hook form dtreact hooks forms examplereact hook with react hookform stack overflowreact hooks formnreact hook form typescript routerreact hook form do you have to install ituseform hook typescriptcreatestore react hook form examplewatch on material ui component react hook formreact form hooks examplereact form hoookreact hook form get form namereact hook form install typesadd icons to react hook formyupresolver react hook form typescript exampleuse form in react hooksreact hook form checkhow to console log react hook form react hook form validatereact hook form register optionsreact quill with 22react hook form 22 site 3astackoverflow comreact hook form typescript watchreactjs validation hooksreact js form hookreact hook form usewatchyup react hook form typescriptform provider react hook formreact form hook docsreact hook form yupresolver with typescriptreact hook form with typescripthow to do the validation onchange in react hook form stack overflowreact form with hookyup schema select react hook formreact hook form reacthookform reactreact hook form with reduxreacthookform on submitrequire for react hook formform in reactjs with hooks validation stackoverflowtypescript react react hook form examplereact hook form validation typesreact useform hook form validationaccess form in react hookreact hook form submit buttonreact hook form reactjsreact hook form typescript yup examplereact hooks form selectreact hook form material ui version 7react hook form emailreact hooks formreact js useformreact hook form demoreact hook forms conversational questionairehow send value of form in react hooks via apiselect register min 1 react hooks formreact hook form smart formcontroller in react hook formreact form validationform hookreact hook fomrreact form validation on submitreact hook forms tsreact native react hook formhooks formsreak hook formreact form examples hooksreact hook form controller selectreact functional forms projectreact hook form componentsreact form validation without hookusing react hook form and material uireact forms and hooksreact hook form custom rulesreact hook form check if validreat hook form 27modify input data react hook formreact hook form react select exampleuse react hook form with material uireact material ui formreact hook form select object site 3astackoverflow comreact hook form react jspost react select through react hook formselect box in react hook formreact hook form native validationform validation react using hooksform validation react js hooks stackoverflowhow to create a reusable select field using react hook form 2c react forward ref and material uireact hook form validationrulereact hook form watch exampletypes for react hook form stack overflowreact hook form typescript examplereac hook formmaterial ui react hook form labelreact hooks form examplecan i use react hook form in react nativeselect validation hook form reactreact hook form useform typescriptreact hook form ashow to handle forms with react material ui hooksreact hook form select validationform react hooksuseform react hook5 star rating react typescript material ui react hook formcontroller react hook form select requiredtypescript react hook form watchreact hook form 2c custom validationconst mycompoent react 3afc example to submit the hook form data into djangoreact hook form match material uireact hooks inputmaterial ui controller react hook formreact forms with hooks react hook formselect with react hooks formreact hook form integrate with react selectreact form hooksforms hooksreact hook form hookreact hook form select material ui validationform validation react hooksuse form reactreact hook form react nativereact hooks form with selectreact hook form formprovider typescriptreact hook form reduxreact hook selectreact hook form register pagereact hook form npreact hook form native select 23react hook formhow to initialize values in react hook form stack overflowreact hook forms registerform with react hooksreact hook formsmaterial ui hook useformreact use form frefvalid email react hook formreact hook form age inputhook formreact hook form control typescriptreact form in hooksreact hook form material uihook form react nativereact hook form watchreact form hook usewatchthis form in react hookshow to use react hook form with yup examplereact hook form with material ui textfield email validationselect boxes using react hook formreact hook form yup typescriptform react validationreact hook form material ui textfieldreact hook form with typescript errorsregister react hook formhooks form in reactreact hook form rating material uirequired min charters react formreactform hookhow to validate select option in react hook formreact uhooks formedit react form with hooksreact hookformreact hooks for formsreact hook form onsubmit typescriptuseform in react nativehook react formreact hook form stackblitzreact creatable select hook formhow to use react hook formreact hook form validation with controlyupresolver react hook formhook react formsreact hook form relationshandlesubmit react hook formreact hook form lcreate react checkbox form with hooksuse react hook form iwith tsreact hooks form react nativereact hook form tutorialtypescript react hook form yup validatrionuseform hook in reactmaterial ui react hooks formform onsubmit react hooksreact hook formreact hook form typescriptreact hook form handlereact fokr hookreact hook form validationreact hooks form what is react hook formreact hook form wtchform submit react hookreact hook form validationreact form validation using hooks example stackblitzcreate reuable select field component using react hook form and react forwarf ref with errors and validation with material uireach hook formforms hook reactreact hook form controller materialreact hook formshook formsmaterialui form with react hookmaterial ui and react hook form 7why using react hook formreact forms hooks tutorialreact hook form select required registerreact form hook material uierrors react hook formreact hook form material ui radioform example react hooksreact hook form javascriptreact native hooks formmaterial ui textfield react hook formreact hook form number fielduse form hookmaerial ui react hook formreact hooks 2b formsreact hook form using email js stack overflowuserform react hookreact hook form loginreact hook form dropdownwhat 27s inside the yupresolver react hook formhow to validate react hooks formform hook reactreact hook form typescript react nativeuseform hood reacttouched field react hook formreact hook form validation material uireact hook froms github comreact hook form react datepickerreact js hooks formreactjs form using hooksuse hook formreact hook form comreact hook form material ui typescriptreact select react hook formreact hook form typescriptrules in react hook formshook form react same view site 3astackoverflow comtypescript react react hook formsimple form validation reactreact hook form email site 3astackoverflow comreact hook formnreact useform loginreact hook form with enumreact select with react hook formreact hook form 2c controller 2c material ui examplesreact hook form validation websitereact hook form sandbox 5dforms react hookshints react hook formuseform hook tutorial react hook form typescript stack overflow 22react select 22 hook forminput validation react hooksreact hook form controller validationreact hook form options 3d 7boptions 7dhandle react hook form submissionexample of material ui textfield validationusing react hook form with material uireact hook form with material ui stackoverflowreact use form hookreact hooks form