p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Simplify repetitive form code

Open lindapaiste opened this issue 2 years ago • 0 comments

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 FormField for an input with a label and an optional error message.
  • Create logic component FinalFormField which uses the Form component from the react-final-form package and passes the props from the generated field down to the FormField UI.
  • Use this new FinalFormField component in forms:
    • AccountForm
    • LoginForm
    • ResetPasswordForm
    • SignupForm

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 develop branch.
  • [ ] is descriptively named and links to an issue number, i.e. Fixes #123

lindapaiste avatar Jun 04 '23 20:06 lindapaiste