Skip to content

Instantly share code, notes, and snippets.

@Almazatun
Almazatun / useForm.md
Last active October 20, 2024 15:53
Costume useForm hook
export const useForm = <C, S = { [key: string]: string }>
(
    callback: (C?: any) => void,
    initState: S,
    validator: (validationData: S) => { errors: Array<string>, valid: boolean }
) => {

    const [values, setValues] = useState<S>(initState)