Next.js Discord

Discord Forum

Spreading register of hook form and using it in another component

Answered
Tan posted this in #help-forum
Open in Discord
TanOP
I am passing register using spread operator. It works when I use on the page its fine. But when I use another component it is not why ??

This is my input component :

export const TestInput = ({ ...props }) => {
  return <input {...props} />;
};

I am using it like this :
console.log(watch("name"))
 <TestInput {...register("name")} /> // THis doesnt work
 <input {...register("name")} /> // This works 
Answered by Tan
It was due to I didn't passed got ref in child component
View full answer

1 Reply

TanOP
It was due to I didn't passed got ref in child component
Answer