react-hook-form / documentation

📋 Official documentation
http://react-hook-form.com
MIT License
726 stars 1.04k forks source link

Extend documentation with section on new transformed values type `TTransformedValues` of `useForm` and `SubmitHandler` #1082

Open maurer2 opened 3 months ago

maurer2 commented 3 months ago

Hello, the useForm hooks and SubmitHandler method seem to have gotten updates to work better with resolvers that transform input data and return said data with different shapes, for example z.boolean().transform((value) => (value ? "Yes" : "No")),, which transforms the field value from boolean to the union type "Yes" | "No". When adding a third type parameter to useForm, e.g. const methods = useForm<TFieldValues, undefined, TTransformedValues>(), the submit method can now be used with the correct transformed type, e.g. SubmitHandler<TTransformedValues> without getting a type error. This was first discovered here: https://github.com/react-hook-form/documentation/issues/1078. As suggested in that thread, it might be helpful to extend the documentation to describe how the new feature works.

Cheers

vercel[bot] commented 3 months ago

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

Name Status Preview Comments Updated (UTC)
react-hook-form-website ❌ Failed (Inspect) Oct 27, 2024 1:48pm