I want to use the same onChange
handler for a series of inputs.
<input onChange={this.handleInputChange}
type="text"
data-input-name="name"
value={this.state.name}/>
so I am attempting to use this html data attribute to store the input's name. When I go to pull the attribute off in JavaScript, I am unable to access it.
handleInputChange = (event) => {
this.setState([event.target.inputName]: event.target.value})
}
I've tried a few permutations to no avail, and it seems difficult to debug since when I log the event.target
I just see an html element in the JavaScript console.
Any advice on how to better debug this or where my syntax is going wrong?