You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I always use yup for validation.
So I wanted to wrap useForm so we can pass through validation and have it automatically wrapped with yupResolver and passed through to resolver.
This works, however something about the way useForm and yupResolver are typed seems to have issue with this.
It's a bit of a hard one to explain so I've added a typescriptplayground link.
Expected behaviour
Wrapping useForm to work the same as an unwrapped variant
typeAutoResolverProps<TFieldValuesextendsFieldValues=FieldValues,TContext=any>=Omit<UseFormProps<TFieldValues,TContext>,'resolver'>&{validation: Parameters<typeofyupResolver<TFieldValues>>[0]};functionuseFormAuto<TFieldValuesextendsFieldValues=FieldValues,TContext=any>({validation, ...props}: AutoResolverProps<TFieldValues,TContext>,){returnuseHookForm({resolver: yupResolver<TFieldValues>(validation),// how do I make this work???
...props});};
This discussion was converted from issue #11594 on March 07, 2024 00:02.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.50.1
Codesandbox/Expo snack
https://www.typescriptlang.org/play?ssl=49&ssc=3&pln=38&pc=1#code/JYWwDg9gTgLgBAbzgTwK5gEoFMDOEA2AbllHAL5wBmUEIcA5AAIAWEEA1pdCAPRS4FiUHDzRh6AbgBQoSLERwAYsCz4AJgDUAhvlS4ANHACqOLIu4AFGmByHUp81Dpacce1gASbdo7oVqtAz8WgDGMAC0rBzhXE6SMuDQ8ABUcC5wAJroVDR09GLxUlIhEAB2OPBqWCAQAMohzNVacAC8megAdBAARgBWWGEAFACUHTjMWmBYgwhScHClWiBYAFztYGMwUMClAOYjHfwAjqjA-GqD9JTA+PhwwPAQqDD0w1Jkw9JSMMhTcAAiWhgWlqEz+bSyGwAkqVKCQACq-LAAHh+UwglDgVRq9UaIC0AD4vlIeDw4DBmMBXAB3aDsHBSdxeDi+GZzOD8PBEEhrMTYLlCQbYuoNJrDfTsqqULSofAwbS6XBrWbzeaLZZreiNW4QegS1ULCAwGG4pqagCM9HZZHenyKlFQpTCwDKcBwsnwWAA6lBJlMoMj4cpVJodHpXFgAB4wLClNSuYPqBXh1pKFRJsMGODwgDCZRj0dTWlKyAJg3ZYGsODWJjMlirgcTocVtmzedKBZgBIlw0QRXm-BgqCgpTcpmZPm4g0rEBsdrIX1JFKpaXweDgtKg9Kk7vAnp9fpIbIHAm5UF56H5giPwtN+PFkqw0tl8sz1b7BvVqwY2vwuv1qqlEaJqiviFpWvMNofF8aJYHAACCzwQFeZ5WLOOCNumzYplGMZxgmWHJrgqZNkRra5vmuFFiWBKpgA8iADzIrWvhoTYmEhmRhgUR2uHdkEp5CPQtEAGQfnAhA6MAahAi6pRrBYWi+ssMbCKiSIYigl6CSQHEZi2BIEgA2gADAAuu8XwOk6MByWkSEoUIenYcRuGxvGaacW+JGEW+3Htp21GluW8wIJJ+DSbJZSGB0sUzjYZBrIhMDITpUBsRhQa+S2-mUdG3ZSL2KoclgQ4jmOnjeKyxUngKPJaZgaXOWRZbhZFtllOKcCknArDUliEBwFCcD4uwcHLjSdIAPwzey8yxR08UMpB86LmS8KUq4FQ3Hcm70oYVQ4GADzjY05JInAJA0KQWjdBAxBSDKKWOUexVtTJHXyVi1QiniWgAVKMpymRypzQsSzflqqh-nqYNAcapR3lo4HWra0hAA
Steps to reproduce
I always use yup for validation.
So I wanted to wrap
useForm
so we can pass throughvalidation
and have it automatically wrapped withyupResolver
and passed through toresolver
.This works, however something about the way
useForm
andyupResolver
are typed seems to have issue with this.It's a bit of a hard one to explain so I've added a typescriptplayground link.
Expected behaviour
Wrapping useForm to work the same as an unwrapped variant
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions