title: How to use an array with setState?
body: <p>I am currently using the following to map my array to setState but nothing is getting set and no errors are being logged. If I explicitly write it out line by line, it works. Any thoughts or suggestions on how to go about this?</p>
  
  <p><strong>Set State with Array: (Does not setSate)</strong></p>
  
  <pre><code>const myData = ['message', 'photo', 'isLoggedInhoto'];
  const newData = [];
  
  {[...Array(myData.length)].map((x, index) =&gt;
    newData.push(myData[index])
  )}
  
  this.setState({
    newData: localStorage.getItem(newData),
  })
  </code></pre>
  
  <p><strong>Line by line (This works and does setState):</strong></p>
  
  <pre><code>this.setState({
    message: localStorage.getItem('message'),
    photo: localStorage.getItem('photo'),
    isLoggedIn: localStorage.getItem('isLoggedIn')
  })
  </code></pre>