Grouping Field Data
useFluentForm
returns multiple objects containing data for each field: values
, errors
, fields
etc..
These field data are grouped by their concerns (e.g. the concern of values
is to store all current values).
This can be perfectly fine for a lot of apps, but for others it could limit the possiblities to design the architecture.
It might be more useful to put all information, that belongs to a field, into one place. Instead of having values
, errors
, fields
etc. you could've e.g. name
and password
objects that contain properties for values
, errors
, fields
etc..
useFieldData
useFieldData
receives a fluent form instance as parameter and will put all information for each field in a seperate object:
Example
Following example contains a fluent form with two fields: name
and password
. useFieldData
will reorganize the state returned by useFluentForm
and group field data by the field itself: