Closed peeke closed 4 years ago
Although it's not part of the 'official' API I think you can do fieldOrForm.value.subscribe(...)
.
If that works we can document it and with that make it official.
snapshot
is will be part of the API (see #15) So then you can use snapshot.subscribe(form, f)
Say I want to do something effectful with the formState, every time it changes (e.g. store the values in localStorage, so the form can be restored on a reload). What would be the best way to do this?
The initial thought may be to use
useFormFieldValue(form)
, but this will of-course re-render the whole form onChange (which is what this library explicitly wants to prevent.Right now, we made a separate component, which uses this hook and calls a callback prop whenever the value changes. Maybe it would make sense to add an
onChange
property to theuseForm
config?Example: