Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: Add SubmitErrorHandler to typescript example so it matches the javascript example #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Copy link

@faysvas faysvas commented Apr 30, 2025
edited
Loading

When browsing the docs I noticed that the TS and JS Sync examples in the docs for handleSubmit were mismatched.

Specifically, even though an onError handler is defined in the TS example, it isn't passed to handleSubmit.

handleSubmit(1)
handleSubmit(2)

Another idea might be to update both the javascript and typescript examples to include some validation rules, like this one

import React from "react"
import { useForm, SubmitHandler, SubmitErrorHandler } from "react-hook-form"
type FormValues = {
 firstName: string
 lastName: string
 email: string
}
export default function App() {
 const { register, handleSubmit } = useForm<FormValues>()
 const onSubmit: SubmitHandler<FormValues> = (data) => console.log(data)
 const onError: SubmitErrorHandler<FormValues> = (errors) => console.log(errors);
 return (
 <form onSubmit={handleSubmit(onSubmit, onError)}>
 <input {...register("firstName"), { required: true }} />
 <input {...register("lastName"), { minLength: 2 }} />
 <input type="email" {...register("email")} />
 <input type="submit" />
 </form>
 )
}

from the TS section

Copy link

vercel bot commented Apr 30, 2025
edited
Loading

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hook-form-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 11:14pm

Copy link

netlify bot commented Apr 30, 2025
edited
Loading

Deploy Preview for sage-cassata-31d224 ready!

Name Link
🔨 Latest commit 1d0dd2e
🔍 Latest deploy log https://app.netlify.com/projects/sage-cassata-31d224/deploys/6882be087f2d260008f2d609
😎 Deploy Preview https://deploy-preview-1140--sage-cassata-31d224.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

sorry for the late review, looks like it's already been updated. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /