title: Where to set state after making an async call?
body: <p>I am trying to pull some data from dynamo db, store it in my local state and then do things with it. I can pull the data put I think I might need to handle async stuff, so Im using async await</p>
  
  <pre><code>async componentDidMount() {
  //aws secret key stuff here
  const ddb = new AWS.DynamoDB({ apiVersion: '2012-10-08' });
      const res = await ddb.scan(params, (err, data) =&gt; {
        if (err) {
          console.log(err, err.stack);
        } else {
          console.log(data);
        }
      });
      this.setState({ products: data })
  }
  </code></pre>
  
  <p>I have a couple of questions. Im basically wanting to wait till the scan completes so I know that the data has been pulled successfully and then i can set state.</p>
  
  <p>Firstly the linter is moaning that I should not set state in componentDidMount, so where should I set it?</p>
  
  <p>Secondly, is the right way to await for some request to complete before utilising the data?</p>
  
  <p>I did a <code>console.log(data)</code> where I have <code>this.setState({products: data})</code> and it logged the correct thing.</p>
  
  <p>but when I try and iterate over my data like so:</p>
  
  <pre><code>{this.state.products.Items.map((product) =&gt; (
  </code></pre>
  
  <p>I get cant read map of undefined??</p>