Some 'options' missing from register #9094
-
ProblemAccording to the docs, register('firstName', {
onChange: (e) => console.log(e)
}) However, in our React + TypeScript based project, we do not have access to this. I've also tried updating to the latest version of Current versions:"react-hook-form": "^7.11.1",
"react-dom": "^17.0.0", Trying to use as such:<TextInput
required
label="Name"
error={errors.name?.message}
placeholder="Enter a name"
{...register('name', {
...nameRules,
validate: validateName,
onChange: (e) => console.log(e)
})}
/> Error on line with
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
@mrigankdoshy : It seems you mis-understand the documentation, "onChange" is a prop of "register" meaning it's included inside the object value returned from called "register". It was exactly right there in the documentation url https://react-hook-form.com/api/useform/register Please read the documentation carefully next time and also the source code with typescript definition. |
Beta Was this translation helpful? Give feedback.
-
@mrigankdoshy : Oh, I see , you're using the new options added for version 7. Could you please share what your typescript version ? Here is the working codesandbox: https://codesandbox.io/s/register-forked-9g9ene?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
@mrigankdoshy : Oh, I see , you're using the new options added for version 7. Could you please share what your typescript version ?
Here is the working codesandbox: https://codesandbox.io/s/register-forked-9g9ene?file=/src/App.js