-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes bug with isValid & isSubmitted states #33
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,7 @@ export const useRemixForm = <T extends FieldValues>({ | |
dirtyFields, | ||
isDirty, | ||
isSubmitSuccessful, | ||
isSubmitted, | ||
isSubmitting, | ||
isValid, | ||
isValidating, | ||
touchedFields, | ||
submitCount, | ||
|
@@ -81,6 +79,10 @@ export const useRemixForm = <T extends FieldValues>({ | |
validKeys, | ||
); | ||
|
||
const isValid = !(Object.keys(errors).length > 0); | ||
const isSubmitted = | ||
data && Object.keys(data).length > 0 && isValid ? true : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also when is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is submited is set as soon as the form is submitted. It will stay submitted until reset is called. So this should be isSubmittedSuccessfully instead. |
||
|
||
return { | ||
...methods, | ||
handleSubmit: methods.handleSubmit( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be formErrors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should make a difference but I'm updated it.