You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a React app and need to disable the form fields during the login process to prevent users from submitting multiple requests or interacting with the form while waiting for the server response.
Here's the situation:
I have a login form with email, password fields, and a submit button.
When the user clicks "Login," I want to disable all fields and the button until I get a response from the server.
I'm considering two approaches to achieve this:
Using isSubmitting: Disable fields while the form is being submitted.
Using a loading state (isLoading): Disable fields while waiting for the server response after making the request.
Which approach is better for this scenario?
Should I use isSubmitting from React Hook Form (RHF), or is it more appropriate to manage a loading state (isLoading) myself?
Does anyone have experience with this and can share the approach they use?
I’d appreciate any advice or examples on how to handle this effectively. Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I'm working on a React app and need to disable the form fields during the login process to prevent users from submitting multiple requests or interacting with the form while waiting for the server response.
Here's the situation:
I have a login form with email, password fields, and a submit button.
When the user clicks "Login," I want to disable all fields and the button until I get a response from the server.
I'm considering two approaches to achieve this:
Using isSubmitting: Disable fields while the form is being submitted.
Using a loading state (isLoading): Disable fields while waiting for the server response after making the request.
Which approach is better for this scenario?
Should I use isSubmitting from React Hook Form (RHF), or is it more appropriate to manage a loading state (isLoading) myself?
Does anyone have experience with this and can share the approach they use?
I’d appreciate any advice or examples on how to handle this effectively. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions