dy / unihooks

Universal unreacted hooks
MIT License
21 stars 1 forks source link

useInput #21

Open dy opened 4 years ago

dy commented 4 years ago

Must useInput(name) create ref, if no corresponding element found?

let [ref, setValue] = useInput(name)

Nope, value must be first, ref is an argument.

But what if combine value with input?

let [{ value, ref, error, disabled }, { disable, validate, set, get, reset }] = useInput(name, default)
// or better keep convention
let [value, { ref, error, disabled, disable, validate, set, get, reset }] = useInput(name, default)
let { value, ref, error, disabled, disable, validate, set, get, reset } = useInput(name, default)