reactjs - How do I store a number of data in an input field so that I can access the data on event as event.target.value or event.target.name? -
i have input field so:
<input name="name" id="name" onchange(event => onchange(event)) />
i can use input properties name, id or ref fields store data in input field on input onchange
, in order able perform following.
onchange(event) { data = this.state.data; data[event.target.id] = event.target.id this.setstate({ data }); }
what if have many values store in input field? possible set object multiple values in input field? e.g. if id object, like, event.target.id.name
, event.target.id.age
, event.target.id.address
. i'm aware id not correct property store multiple data. however, i'm not sure id or other property of input can store object.
data[event.target.property] = event.target.property
what correct approach this?
Comments
Post a Comment