Skip to content

Instantly share code, notes, and snippets.

@jesperbjensen
Created August 12, 2019 07:43
Show Gist options
  • Save jesperbjensen/7af8234436b9510d1e038a32ea1dd5ef to your computer and use it in GitHub Desktop.
Save jesperbjensen/7af8234436b9510d1e038a32ea1dd5ef to your computer and use it in GitHub Desktop.
Hooks Form Prototype Example
function MyFormSample() {
const form = useForm({
firstName: useField({ name: "Firstname", validators: [requiredValidator] }),
lastName: useField({ name: "Lastname", validators: [requiredValidator] })
});
return (
<div>
<TextField {...textFieldFieldProps(form.firstName)} />
<TextField {...textFieldFieldProps(form.lastName)} />
<Button disabled={!form.allFieldsValid}>Create</Button>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment