TypeError: Cannot read property 'value' of null reactJs

I am getting the following error TypeError: Cannot read property ‘value’ of null what do I need to do with value in this case please help me. Do I need to assign a value to value

function makeSearch() {
  var qty = document.getElementById('qty').value;
  if (qty > 5) {
    alert("Maximum 5 toy available.")
    return false
  }
  var cname = document.getElementById('cname').value;
  var tenure = document.getElementById('tenure').value;
  var toy = document.getElementById('toy_name').value;
  var rent = qty * tenure * toy;
  var answer = window.confirm("Total rental cost = " + rent);
  if (answer) {
    alert("Thank you for order Mr/Ms/Mrs: " + cname);
    window.location.reload();
  } else {
    alert("Order cancelled.")
    window.location.reload();
  }
  return false
}

code after
return :

  <
  tr >
  <
  td >
  Number Of toys available <
  /td> <
td >
  <
  input type = "number"
name = "avail"
id = "avail"
value = ""
readonly ref = ""
required > < /input> < /
  td > <
  /tr> <
tr >

4 thoughts on “TypeError: Cannot read property 'value' of null reactJs”

Leave a Comment