title: React : why state change when try to change it in immutable way , before calling the setState
body: <p>When I try to change state immutable way in <code>React</code>, it is changing the state before I call <code>setstate</code>, which confused me for 3 days now.</p>
  
  <p>This is the method I call in the <code>onClick</code> event:</p>
  
  <pre><code>share = (indexFolder) =&gt; {
      console.log(this.state.folderInfo);
      const updateFolderInfo = [...this.state.folderInfo];
      updateFolderInfo[indexFolder].isProcessing = false; 
  
      //state**is already changed**strong text** when console **
      console.log(this.state.folderInfo);
  
      this.setState({
              folderInfo : updateFolderInfo,
      })
      // the setState call do not take effect here 
  }
  </code></pre>
  
  <p>This is where the method is executed:</p>
  
  <pre><code>&lt;Folder key={folder._id}
          sharing={this.state.folderIsProcessing}
          folder={folder} 
          delete={() =&gt; this.delete(index)}
          share={() =&gt; this.share(index)} /&gt;
  //I'm passing share function as props in here ^ , and use it on 
  //click event in the Folder component . 
  </code></pre>
  
  <p>Any suggestions why this is happening?</p>