Typescript typing for registers as a prop. #8418
Unanswered
systemi-dongtdao
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I just tried this and this seems to fix my errors but i feels like im doing something wrong. type TMyCustomComponent = {
register: UseFormRegisterReturn
}
export default const MyCustomComponent = ({register}): ReactElement => {
....
return (
<div>
<input {....register} />
</div> )
} const {register, ...} = useForm({defaultValues: {bar: ""})
<MyCustomComponent
register={register("bar")}
/> Please let me know if this is a possible solution. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings react-hook-form.
As the title implies im having some issues with typing and react-hook-form.
Basically i have a custom component that i wish to pass down the
register
fromuseForm
I was having issues with typing the register first but this post helped me come to the
UseFormRegister<FieldValues>
as an answer.But then in the parent i was getting another error
From the post that i first found, i thought maybe using
UseFormRegister<FieldValues
would fix things, but i guess there was something that needed? Maybe i didnt properly use useForm.My apologies from my question is probably more towards typescript than maybe react-form-hook. But i was wondering if anyone can point me in the right direction and provide some guidance.
Beta Was this translation helpful? Give feedback.
All reactions