p5.js-web-editor
p5.js-web-editor copied to clipboard
Simplify repetitive form code
Background:
In forms which use react-final-form we have a lot of repeated boilerplate. For example every field has the same error code:
{field.meta.touched && field.meta.error && (
<span className="form-error">{field.meta.error}</span>
)}
Changes:
- Create UI component
FormFieldfor aninputwith alabeland an optional error message. - Create logic component
FinalFormFieldwhich uses theFormcomponent from thereact-final-formpackage and passes the props from the generatedfielddown to theFormFieldUI. - Use this new
FinalFormFieldcomponent in forms:AccountFormLoginFormResetPasswordFormSignupForm
I have verified that this pull request:
- [x] has no linting errors (
npm run lint) - [x] has no test errors (
npm run test) - [x] is from a uniquely-named feature branch and is up to date with the
developbranch. - [ ] is descriptively named and links to an issue number, i.e.
Fixes #123