diff --git a/docs/3.1.x/react-hooks-forms.md b/docs/3.1.x/react-hooks-forms.md index f4efec13..9d7ec913 100644 --- a/docs/3.1.x/react-hooks-forms.md +++ b/docs/3.1.x/react-hooks-forms.md @@ -19,8 +19,9 @@ import React from 'react'; import { useForm, Controller } from 'react-hook-form'; function FormHookExample() { - const { control, handleSubmit, errors } = useForm(); - const onSubmit = (data) => { + const { control, handleSubmit, formState: {errors} } = useForm(); + + const onSubmit = (data: any) => { console.log('submiting with ', data); }; return ( @@ -29,16 +30,16 @@ function FormHookExample() { First Name ( + render={({field: {onChange, onBlur, value}}) => ( onChange(val)} + onChangeText={val => onChange(val)} value={value} /> )} name="firstName" - rules={{ required: 'Field is required', minLength: 3 }} + rules={{required: 'Field is required', minLength: 3}} defaultValue="" /> @@ -49,11 +50,11 @@ function FormHookExample() { Last Name ( + render={({field: {onChange, onBlur, value}}) => ( onChange(val)} + onChangeText={val => onChange(val)} value={value} /> )} @@ -68,22 +69,24 @@ function FormHookExample() { Age ( + render={({field: {onChange, onBlur, value}}) => ( onChange(val)} + onChangeText={val => onChange(val)} value={value} /> )} name="age" - rules={{ min: 18, required: 'Age is required' }} + rules={{min: 18, required: 'Age is required'}} defaultValue="" /> {errors.age?.type === 'required' ? errors.age?.message - : errors.age?.type === 'min' ?? 'Under age'} + : errors.age?.type == 'min' + ? 'Under age' + : null}