Prevent calling handleSubmit
method when reset
is invoked
#11559
-
Hello all, I want to initialize the useEffect(() => {
setUser(userData?.[0]);
}, [userData]); where My const formMethods = useForm<IUserFormFields>(
{
mode: 'onBlur',
reValidateMode: 'onChange',
criteriaMode: 'all',
defaultValues: {
name: '',
title: '',
preferences: {},
},
},
); This is how I am updating the useEffect(() => {
reset({
name: user?.name,
title: user?.description,
preferences: makePrefrences(user?.pref),
});
}, [user, reset]); A list of users is loaded in a leftnav, and as a super user I am able to select any user to edit via the state change |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You probably haven't set the reset button inside your form element to |
Beta Was this translation helpful? Give feedback.
I don't have a reset button, I am invoking
reset
viauseEffect
every time I as the superuser change the user to edit so thedefaultValues
are updated and form pre-fills the values of the user.