Skip to content

Instantly share code, notes, and snippets.

@jordangarcia
Created August 6, 2018 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordangarcia/647e59ed43a9f32ae82af7c408c3aec1 to your computer and use it in GitHub Desktop.
Save jordangarcia/647e59ed43a9f32ae82af7c408c3aec1 to your computer and use it in GitHub Desktop.

React Form Abstraction

What problems are we trying to solve?

  1. There is not a generic solution for handling dirty state checking and reverts throughout our codebase.

  2. Validation is a mess, either it's duplicated as inline validation in the "Input" component and in the "Form" component. Other places it exist in the parent component and passed down through props to the "Input", this means our inputs require the parent component to know and do a ton of validation making them no longer easily portable.

Requirements for a good React Form Abstraction

  1. Generalizes and abstracts form dirty state, and reverts
  2. Allows to define validation once for an input while keeping form inputs portable and easily composeable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment