kettanaito / react-advanced-form

Functional reactive forms. Multi-layer validation, custom styling, field grouping, reactive props, and much more.
https://redd.gitbook.io/react-advanced-form
MIT License
217 stars 24 forks source link

Support "pristine" fieldState property #353

Closed kettanaito closed 5 years ago

kettanaito commented 5 years ago

What

I suggest to support fieldState.pristine property.

Why

That property would indicate whether a field has been edited as opposed to its initial state. Right now there is no way to distinguish this state, which results into people using stateful fields to track this state transitions. I would strive for field components to be stateless functional component.

Specification

The pristine property of a field's state represents whether a user has changed the field's value.

  1. Set pristine: true in the initial field state.
  2. Set pristine: false whenever a value change occurs.
  3. Set pristine: true on form reset.
  4. Clearing the form has no effect.