I am new to react.
I have a input text like so
<input type="text" class="form-control" placeholder="Number Only"
                                      value={that.state.value}
                                      ref={"qtype3" + item.questionId}
                                    />
now in a method I want to get the value inputted in the textbox,so i wrote following block in the method:
const uniqueNames = Array.from(new Set(this.state.arrrefs));
    if (uniqueNames.length > 0) {
      for (let i = 0; i < uniqueNames.length; i++) {
        var inval = uniqueNames[i];
        var ans = this.refs.inval.value;
        var newans = {
          taskId: this.props.location.state.tskId,
          userId: this.props.location.state.userid,
          questionId: "",
          answer: ans
        };
        this.state.radioObj.push(newans);
      }
    }
here arrrefs is an array in the state with refs of several textboxes. In the variable inval I am getting the first value of the arrrefs. but i am getting the exception in the line var ans = this.refs.inval.value;
TypeError: Cannot read property 'value' of undefined
If I pass a hardcode value in line this.refs.inval.value instead of inval I am getting response.
for example, my uniqueNames = ["qtype3800316", "qtype3800317", "qtype3800318", "qtype3800324"]
so i want this.refs.qtype3800316.value
What am I doing wrong here?
 
     
    