const [user, setUser] = useState({})
const reg = (e) => {
const {name, value} = e.target
setUser(user[name] = value)
}
<input
name='name'
onChange={reg}
value={user.name} />
<input
name='surname'
onChange={reg}
value={user.surname} />