reset form and doing a focus on an input is problematic #2746
-
So, not sure if this might be considered a bug or not, but just thought I'd post it here for a little discussion on it first. This hung me up for a bit. I thought there was a problem going on with my component when trying to do a focus on it, but it turns out if you use the reset function from useForm just before the focus on the input, something is happening to make it lose focus asynchronously. Once I was able to figure out that was going on I just threw an await on reset to be sure it was done to do the focus, but should there be something to prevent that or at least some sort of documentation so this doesn't hang someone else up? Here's my code for the specific areas...
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
hey @Bruqui as far as I know, we don't do anything async in reset, but this could be the reason why you are having an issue: https://github.com/react-hook-form/react-hook-form/blob/master/src/useForm.ts#L1114 we do invoke native form |
Beta Was this translation helpful? Give feedback.
hey @Bruqui as far as I know, we don't do anything async in reset, but this could be the reason why you are having an issue:
https://github.com/react-hook-form/react-hook-form/blob/master/src/useForm.ts#L1114
we do invoke native form
reset
API.