React Multiple Inputs

Handling multiple input fields with a single handler.

React Multiple Inputs

If you have many form inputs, you can make a name attribute to each element.

To let the handler function know which input triggered the change, use event.target.name.

Use the spread syntax ... to update only the specific property in the state object.

Example

setInputs(values => ({...values, [name]: value}))