final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

How to set Form's values interface? #454

Open ackvf opened 5 years ago

ackvf commented 5 years ago

From the typings, I can see that Form props are of type FormProps from 'react-final-form' and that extends Config from 'final-form'. Config accepts type generics that eventually set the type of values ->

Config<FormData = object> {
  onSubmit: (values: FormData) // ...
}

How can I configure the values type from within the Form itself so that I have intellisense within onSubmit and validation handlers and everywhere else where values appear?

PS: shouldn't the values here be also of FormData

  validate?: (values: object)
  initialValues: object
stramel commented 5 years ago

I think what you want is the generic typing of Form. See #426

ackvf commented 5 years ago

Amazing!