Check out example codes for "filter() array of objects on change react". It will help you in understanding the concepts better.

Code Example 1

const handleChange = (e) => {
      const id = hospitalsDetails.filter(obj => obj.hospitalName == e.target.value)
      setCurrentApp({ ...currentApp, [e.target.id]: e.target.value, ["hospitalID"]: id.hospitalID })  
}

Learn ReactJs, React Native from akashmittal.com