@@ -445,16 +445,11 @@ npm install @hookform/resolvers
445445
446446<TabGroup buttonLabels = { [" Yup" ," Zod" ," Joi" ," Ajv" ," Vest" , " Custom" ]} >
447447
448- ``` typescript copy sandbox="https://codesandbox.io/s/react-hook-form-apply-validation-ts-forked-nmbyh"
448+ ``` tsx copy sandbox="https://codesandbox.io/s/react-hook-form-apply-validation-ts-forked-nmbyh"
449449import { useForm } from " react-hook-form"
450450import { yupResolver } from " @hookform/resolvers/yup"
451451import * as yup from " yup"
452452
453- type Inputs = {
454- name: string
455- age: string
456- }
457-
458453const schema = yup
459454 .object ()
460455 .shape ({
@@ -464,7 +459,7 @@ const schema = yup
464459 .required ()
465460
466461const App = () => {
467- const { register, handleSubmit } = useForm < Inputs > ({
462+ const { register, handleSubmit } = useForm ({
468463 resolver: yupResolver (schema ), // yup, joi and even your own.
469464 })
470465
@@ -478,7 +473,7 @@ const App = () => {
478473}
479474```
480475
481- ``` typescript copy sandbox="https://codesandbox.io/s/react-hook-form-zod-resolver-ts-example-forked-w72vp"
476+ ``` tsx copy sandbox="https://codesandbox.io/s/react-hook-form-zod-resolver-ts-example-forked-w72vp"
482477import { useForm } from " react-hook-form"
483478import { zodResolver } from " @hookform/resolvers/zod"
484479import * as z from " zod"
@@ -491,16 +486,15 @@ const schema = z.object({
491486type Schema = z .infer <typeof schema >
492487
493488const App = () => {
494- const { register, handleSubmit } = useForm < Schema > ({
489+ const { register, handleSubmit } = useForm ({
495490 resolver: zodResolver (schema ),
496491 })
497492
498- const onSubmit = (data : Schema ) => {
499- console .log (data )
500- }
501-
502493 return (
503- < form onSubmit = {handleSubmit(onSubmit )}>
494+ <form onSubmit = { handleSubmit ((data ) => {
495+ // handle inputs
496+ console .log (data );
497+ })} >
504498 <input { ... register (" name" )} />
505499 <input { ... register (" age" , { valueAsNumber: true })} type = " number" />
506500 <input type = " submit" />
@@ -509,7 +503,7 @@ const App = () => {
509503}
510504```
511505
512- ``` typescript copy sandbox="https://codesandbox.io/s/react-hook-form-joiresolver-v6-ts-forked-5pseh"
506+ ``` tsx copy sandbox="https://codesandbox.io/s/react-hook-form-joiresolver-v6-ts-forked-5pseh"
513507import { useForm } from " react-hook-form" ;
514508import { joiResolver } from " @hookform/resolvers/joi" ;
515509import Joi from " joi" ;
@@ -534,15 +528,15 @@ const App = () => {
534528
535529 return (
536530 <form onSubmit = { handleSubmit (onSubmit )} >
537- < input {... register ("name "} / >
538- < input type = " number" {... register ("age "} / >
531+ <input { ... register (" name" ) } />
532+ <input type = " number" { ... register (" age" ) } />
539533 <input type = " submit" />
540534 </form >
541535 );
542536}
543537```
544538
545- ``` javascript copy sandbox="https://codesandbox.io/s/react-hook-form-ajvresolver-vr3imc"
539+ ``` tsx copy sandbox="https://codesandbox.io/s/react-hook-form-ajvresolver-vr3imc"
546540import { useForm } from " react-hook-form"
547541import { ajvResolver } from " @hookform/resolvers/ajv"
548542
@@ -586,7 +580,7 @@ const App = () => {
586580}
587581```
588582
589- ``` javascript copy sandbox="https://codesandbox.io/s/vest-8q874"
583+ ``` tsx copy sandbox="https://codesandbox.io/s/vest-8q874"
590584import * as React from " react"
591585import { useForm } from " react-hook-form"
592586import { vestResolver } from " @hookform/resolvers/vest"
@@ -633,7 +627,7 @@ const App = () => {
633627}
634628```
635629
636- ``` typescript copy sandbox="https://codesandbox.io/s/react-hook-form-customresoliver-ts-v7-juc63"
630+ ``` tsx copy sandbox="https://codesandbox.io/s/react-hook-form-customresoliver-ts-v7-juc63"
637631import * as React from " react"
638632import { useForm } from " react-hook-form"
639633import * as Joi from " joi"
0 commit comments