function BasicForm() {
const Input = ({ node, handler }) => {
const { value = '', label } = node
return (
<div class="field-input">
{label && <div>{label}</div>}
<input value={value} onChange={handler.handleChange} />
</div>
)
}
const Submit = ({ node }) => {
return <button class="btn-submit" type="submit">{node.text}</button>
}
const form = useForm({
onSubmit(values) {
alert(JSON.stringify(values, null, 2))
console.log('values', values)
},
components: {
Input,
Submit,
},
children: [
{
label: 'First Name',
name: 'firstName',
component: 'Input',
value: '',
},
{
label: 'Last Name',
name: 'lastName',
component: 'Input',
value: '',
},
{
component: 'Submit',
text: 'submit',
},
],
})
return <Form form={form} />
}