title: Trying to setState using eval() function (React Native)
body: <p>I'm trying to set multiple states in a for loop to be false or true depending on whether they meet the (if statement) requirement. The for loop will loop through an array of strings, each string represents a state. But I can't seem to use eval within this.setState function...</p>
  
  <p>I have tried researching online but none of the solutions match my problem or what I'm trying to solve. I even tried eval(this.state.anything) = false but it still doesn't work and shows a left hand assign invalid error.</p>
  
  <pre><code>let businessState = [
        "this.state.groupName",
        "this.state.groupOwnerName",
        "this.state.groupDesc",
        "this.props.profile._id",
        "this.state.businessName",
        "this.state.businessDesc",
        "this.state.businessRegNo",
        "this.state.businessType",
        "this.state.businessEmail",
        "this.state.businessTel",
        "this.state.businessWeChat",
        "this.state.businessRegPhotoUri",
        "this.state.businessSignPhotoUri"
      ];
  
  var temp = ""
  for (i = 0; i &lt; businessState.length; i++) {
    if (eval(businessState[i]) == ""){
      temp = businessState[i]+ "Error"
  
      this.setState({
        eval(temp): true
      })
    }
  }
  </code></pre>
  
  <p>As you can see from the code above, I want to evaluate the state, and if the value that this particular state holds is an empty string "", I want to set this state name + "Error" (For example, if this.state.email is empty string "" I want to set this.state.emailError to true. </p>