Open
Description
Hey I think it would be kinda cool if it worked something like this:
const { onSubmit, firstName, lastName } = useForm({
initialValues: { firstName: 'Alex', lastName: 'Cory' },
firstName: {
// A. whatever you return would set whatever the value is for this form input
onChange: e => {
return e.target.value
},
// B. pull out the stuff you need to set the value. (this way seems more extensible
onChange: ({ event, value, set }) => {
set(event.target.value)
}
// you could also have formatters for your value
value: ({ value, set }) => {
// do some custom "getter" logic (i.e. say this was a number input)
// this would be similar to doing `get value() {}` in a class and then doing <input value={this.value} ... />
set(Number(value))
// or again, you could just use the "return" value
}
},
lastName: {}
})
<input {...firstName} />
Metadata
Metadata
Assignees
Labels
No labels