title: Uncaught (in promise) ReferenceError: data is not defined in react component
body: <p>I'm passing a simple JSON object from the back-end to the front-end <code>{data: "test"}</code>. I got the following error on the react side <code>Uncaught (in promise) ReferenceError: data is not defined</code>. I'm pretty sure I'm missing something obvious. Here is my Component:</p>
  
  <pre><code>export default class App extends Component {
    state = { data: null };
  
    componentDidMount() {
      fetch('/data',    {
            method: 'GET',
            withCredentials: true,
            headers: {
      'Content-Type': 'application/json', 
      'Access-Control-Allow-Origin': '*',
      'Accept': 'application/json' }})
        .then(res =&gt; res.json())
        .then(data =&gt; this.setState({ data }));
    }
  
    render() {
      const { data } = this.state;
      console.log(data)
      return (
        &lt;div&gt;
        &lt;p&gt; test &lt;/p&gt;
        &lt;/div&gt;
      );
    }
  }
  </code></pre>