Definir state usando utilizando Currying - #ReactJS
Bem antes de partir para o exemplo precisamos definir o que Currying?
import React from 'react'
const Form = () => {
const [username, setUsername] = React.useState('')
const [password, setPassword] = React.useState('')
const setInput = (setter) => (event) => {
setter(event.currentTarget.value)
}
return (
<form>
<input value={username} onChange={setInput(setUsername)} />
<input value={password} onChange={setInput(setPassword)} />
</form>)
}