1

I'm using a function component named 'SignIn' which have a form with 2 inputs, email and password, each one has its own useState. So, in order to update the state I'm making an "onChange" on the input like this:

> ```const SignIn = () => {
> 
>     const [email, setEmail] = useState('')
>     const [password, setPassword] = useState('')
> 
>     return (
>         <div className='sign-in'>
>     
>         <form onSubmit={handleSubmit} >
>             <input type="email" name='email' value={email} placeholder="Enter your email"required Onchange={e =>
> setEmail(e.target.value)}/>
>             <label>Email</label>
>             <input type="password" name='password' value={password} placeholder='Enter your password'required Onchange={e =>
> setPassword(e.target.value)}/>
>             <label>Password</label>
> 
>             <input type="submit" value='Submit Form' />
> 
>         </form>
>             
>         </div>```

How can I make something like this to handle both inputs in the same function?

> ```handleChange => (e) =>{     const {name, value} = e
> 
>     **Something for both Set...** ({[name]:value})```
Drew Reese
  • 165,259
  • 14
  • 153
  • 181
Tomas Gil Amoedo
  • 537
  • 3
  • 16

0 Answers0