-
Notifications
You must be signed in to change notification settings - Fork 929
refactor: curry GetFormHelpers #1156
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
+ Coverage 66.24% 66.43% +0.19%
==========================================
Files 255 263 +8
Lines 16120 16426 +306
Branches 156 156
==========================================
+ Hits 10678 10912 +234
- Misses 4335 4390 +55
- Partials 1107 1124 +17
Continue to review full report at Codecov.
|
@@ -49,29 +49,30 @@ export const AccountForm: React.FC<AccountFormProps> = ({ | |||
validationSchema, | |||
onSubmit, | |||
}) | |||
const getFieldHelpers = getFormHelpers<AccountFormValues>(form, 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.
praise: I love this solution, the curry is very clean and reminds me of an improvement upon the old wrappers!
// getIn is a util function from Formik that gets at any depth of nesting | ||
// and is necessary for the types to work | ||
const touched = getIn(form.touched, name) | ||
const apiError = getIn(formErrors, name) |
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.
praise: improve var name
Changes
getFormHelpers
to take two arguments and return a function that takes one argument, so we don't have to repeat args as much. Also adds test coverage for using API errors in the form. In keeping with the existing code, I show the API error if we have both, but I don't have a strong opinion on it.