#Why is automatically wrapping this property suddenly making it invalid?

14 messages · Page 1 of 1 (latest)

wise walrus
#

I am using react-hook-form and you must do useForm({resolver: yupResolver(mySchema)}) which while not difficult isn't optimal, so I wanted to create a wrapper around useForm so I can just do useForm({validation: mySchema}) and it will internally call the base useForm with resolver.

Functionally this is working, but I'm getting an error against the resolver prop and I really can't work out why.

orchid wagonBOT
#
hailwood#0

Preview:```ts
...
type AutoResolverProps<TFieldValues extends FieldValues = FieldValues, TContext = any> = Omit<UseFormProps<TFieldValues, TContext>, 'resolver'> & {
validation: Parameters<typeof yupResolver<TFieldValues>>[0]
};

function autoResolver<TFieldValues extends FieldValues = FieldValues, TContext = any>(
{validation, ...props}: AutoResolverProps<TFieldValues, TContext>,
) {
return useHookForm({
resolver: yupResolver<TFieldValues>(validation), // how do I make this work???
...props
});
};
...```

wise walrus
#

!helper

wise walrus
#

It should be working right?

wise walrus
#

!helper

quiet perch
#

@wise walrus

#

this is where the issue is happening

#

honestly idk how to fix it

#

ngl good luck

wise walrus
#

@quiet perch off topic, but how do you get it to show you the type expanded like that?

quiet perch
#

@wise walrus // ^?

#

make sure the ^ point to the variable