title: In React how can I set state variables in a loop?
body: <p>I have a number of state variables (I am only showing 3):</p>
  <pre><code>class IntroductionPage extends React.Component&lt;SomePageProps, {inId: string,
    i1: string,
    i2: string
  }&gt; {
    constructor(props: any) {
      super(props);
      this.state = {inId:'',
        i1:'',
        i2:''
      };
    }
  </code></pre>
  <p>and I am reading key-value pairs from a DB:</p>
  <pre><code>+------------+------------+------------+
  | start_type | field_name | start_text |
  +------------+------------+------------+
  | 0          | i1         | hi         |
  +------------+------------+------------+
  | 0          | i2         | it's me!   |
  +------------+------------+------------+
  | 0          | i3         | Schoon     |
  +------------+------------+------------+
  
  
  for (var key in response.data) {
    var dat = response.data[key];
    getStartType=dat['start_type']//JSON.stringify(dat['start_type']);
    for (var inner_key in dat) {
      console.log('key=' + inner_key + ' value=' + dat[inner_key]);
    }
  </code></pre>
  <p>gives</p>
  <pre><code>key=start_type value=0
  key=field_name value=i1
  key=start_text value=hi
  ...
  </code></pre>
  <p>Now is there any way I can loop through these retrieved value and set state, for example something like a loop or map version of this:</p>
  <pre><code>this.setState({dat['field_name']:dat['start_text']});
  </code></pre>
  <p>so the first row returned would be fieldname= i1, start_text ='hi' and so the loop would <code>setState ({i1:'hi'})</code>?</p>