score:1

Accepted answer
 const onSearchType = (e) => {
    var inputText = e.target.value.toUpperCase();
    const clone = { ...optionList };
    unitList.forEach((unit, index) => {
      if (unit.substring(0, inputText.length).toUpperCase() === inputText)
        clone[unit] = true;
    });
    setOptionList(clone);
  };

Related Query

More Query from same tag