useForm

A custom React hook for form handling with validation, submission, and data formatting.

# Basic Usage


import { useForm } from 'blackborne/hooks';

const {
  register,
  registerSubmit,
  handleSubmit
} = useForm({ name: '', email: '' });

useForm Hook Return

PropTypeDescription
registerFunctionRegisters a field for validation and tracking. Returns errors, value, and handleChange function.
registerSubmitFunctionRegisters a submit function to be called on form submission.
handleSubmitFunctionHandles the form submission, validating fields before executing the submit function.
handleAssistantFunctionHandles Enter key submission event.
resetFunctionResets the form data to the initial state.
setFormFunctionSets form data, filtering out invalid values.
setFormDataFunctionDirectly updates the form data state.
pendingBooleanIndicates whether form submission is in progress.
watchObjectTracks the current form state.
errorsObjectStores validation errors for each field.