Skip to content

useField ​

Category
Utilities

Hook to manage a form field

typescript
import { useField } from '@siberiacancode/reactuse';

Usage ​

typescript
const { register, getValue, setValue, reset, dirty, error, setError, clearError, touched, focus, watch } = useField();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
params.initialValue?Value-Initial value
params.initialTouched?booleanfalseInitial touched state
params.autoFocus?booleanfalseAuto focus
params.validateOnChange?booleanfalseValidate on change
params.validateOnBlur?booleanfalseValidate on blur
params.validateOnMount?booleanfalseValidate on mount

Contributors ​

Source • Demo