How to set state as an array and how to access them with setState and this.state : <p>I have created an array like this:</p>

<pre><code>state = {
    arr: [ ]
        }
</code></pre>

<p>I want to update state as well as access them </p>

<p>In my function I am using want to use it like </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>func() {
    this.state.arr;   // for accesing the array 
     //remaining codes
    this.setState({arr: this.state.arr.push(2)}); //for updating 
     }</code></pre>
</div>
</div>
</p>

<p>this is resulting in error and wrong outputs there is something wrong in the code that have used </p>
