Form
Form wrapper that runs native validation before your submit handler.
Usage
import {Form} from 'kinu';
<Form onValid={save}>
<Field>...</Field>
<Button type="submit">Save</Button>
</Form>
Exports
| Name | Description | Rendered HTML |
|---|---|---|
| Form | Component | — |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| onValid | any |
— | Called with the submit event when the form passes native validation. When |
| the form is invalid, Form instead prevents submission and focuses the first | |||
| invalid control — so you never manage validation state yourself. |
Notes
- No form-state engine. On submit it runs
checkValidity(): if the form is invalid it blocks submission and focuses the first invalid control; otherwise it callsonValidwith the event. - Pairs with the native-validation CSS layer (
:user-invalid) andField/Field.Error— see the Forms & Validation page. You never managetouchedorerrorsstate. - Bring your own submit in
onValid(e.g.e.preventDefault()then POST).
_Source: src/components/form/index.tsx