how to get value from useForm on change input ? #1098
Replies: 2 comments 6 replies
-
const form = useForm({
defaultValues: {
name: user?.firstName + " " + user?.lastName || "",
},
onSubmit: async ({ value }) => {
console.log(value);
},
validators: {
onChange: (form) => {
console.log("test", form);
},
},
}); this might get you where you want but I think "onChange" is not meant to be used this way. Your linter would cry. |
Beta Was this translation helpful? Give feedback.
6 replies
-
@ahmerarain on the 25/11/24 field.listeners was added, along with the relevant docs. So you can do <form.Field
name="name"
listeners={{
onChange: ({ value }) => {
console.log(value);
// fieldApi is also available here so you can also access its utility functions
},
}}
>
{(field) => (
<input
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
/>
)}
</form.Field> With listeners you can also subscribe to the following events:
|
Beta Was this translation helpful? Give feedback.
0 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.
-
when value changes in input i want to get here instantly
const form = useForm({
defaultValues: {
name: user?.firstName + " " + user?.lastName || "",
},
onSubmit: async ({ value }) => {
console.log(value);
},
});
Beta Was this translation helpful? Give feedback.
All reactions