import { createRoot } from 'react-dom/client' import React from 'react' import { Form, useForm } from 'react-component-form' import type { HandleUseFormCallback } from 'react-component-form' const schema = { inputName: { type: 'string', minLength: 3, maxLength: 20 } } export const Example = () => { const { errors, handleUseForm } = useForm(schema) const onSubmit: HandleUseFormCallback = ( formData, formElement ) => { console.log(formData) // { inputName: 'value of the input validated' } formElement.reset() return null } return (
{errors.inputName != null &&

{errors.inputName[0].message}

}
) } const container = document.getElementById('root') as HTMLElement const root = createRoot(container) root.render()