Code Insights: `useForm` refactoring — lift up useField state to the form hook
Created by: vovakulikov
Part of https://github.com/sourcegraph/sourcegraph/issues/23890
Context
Before this PR we had form field state (value, dirty, valid state, etc) in useField
hook. And this is ok but to be able to implement something like resetForm
method at useForm hook we should have all field state in one place and avoid syncing state in useForm
and useField
hooks.
This PR lifts up form filed state to the useForm hook and makes that useForm
is responsible to pass through field state to the useField
hook by formAPI
object.
This refactoring gives us the opportunity to implement a new API around the useForm
hook such as resetField
or fully controlled form.