I am trying to take input from user and push that input into array of object . It working fine but I face one problem . When I type for exmaple ( Nine ) so it created 4 object inside array . I want only single object and store user value. It created an array like
[
 {name : 'text', value : 'N'}
 {name : 'text', value : 'Ni'}
 {name : 'text', value : 'Nin'}
 {name : 'text', value : 'Nine'}
]Could someone please help me how to resolve this issue. Thanks
Code
 <input
    type="text"
    className="inputStyle"
    placeholder={item.fieldName}
    onChange={(e) =>
    this.generateExtraFieldData(
     e.target.value,
     item.fieldName
    )
   }
/>
generateExtraFieldData = (data, type) => {
    const { optionalFields } = this.state;
    var joined = optionalFields.concat({ name: "text", value: data });
    this.setState({
      optionalFields: joined,
    });
  };
 
     
     
    