title: setState not setting state variable React
body: <p>I'm trying to set state variable to response data from api call but unable to do so . I have division array in responseJson which i'm trying to set to divisions array in state. I'm getting the responseJson values on console.log but when i'm trying setState({...this.state,divisions:responseJson.division}) i'm not getting any data on console.</p>
  
  <p><strong>state</strong></p>
  
  <pre><code>    this.state={
      token: data.token,
      role: data.role,
      userId: data.userId,
      organizationId: data.organizationId,
      organizationName: data.organization_name,
      workspacePP: false,
      workspaces: [],
      divisions:[],
      addWorkspace: null,
      isDivisionViewable:false,
      divisionName:null
  
  };
  </code></pre>
  
  <p><strong>function addDivision</strong></p>
  
  <pre><code> addDivision=()=&gt; {
  
   const uri = `${APPURL}/workspace/division/create`;
   console.log('dddddd',this.state)
    fetch(uri, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${this.state.token}`
      },
      body: JSON.stringify({
                workspace_id: this.state.workspaces[0].workspace_id,
                organization_id: this.state.organizationId,
                division:this.state.divisionName
          }),
      }).then((res)=&gt;res.json()).then(responseJson=&gt;{
  
            if(!responseJson.status){
              message.error(responseJson.error);
              return;
            }
            console.log('dddd',responseJson);
  
            this.setState({...this.state,divisions:responseJson.division})
  
      })
      console.log(this.state)//returns empty array
    }
  </code></pre>
  
  <p><strong>responseJson</strong></p>
  
  <pre><code>{status: true, division: Array(1), created_at: {…}, user: {…}}
  created_at:
  updated_at: ["2019-03-09 14:05:26"]
  __proto__: Object
  division: Array(1)
  0: {id: 5, userid: "t863060h", workspace_id: "ROPHV6W", workspace_name: 
  "workspace", created_at: "2019-03-09 13:39:31", …}
  length: 1
  __proto__: Array(0)
  status: true
  user:
  created_at: "2019-03-08 18:29:56"
  email: "trycatchh@mail.com"
  email_verification: 1
  id: 1
  loginStatus: 0
  mobile_otp: 0
  mobile_verification: 0
  phone: "9632587410"
  role: "Admin"
  slug: ""
  status: 2
  team: null
  uid: null
  </code></pre>
  
  <p>updated_at: "2019-03-08 18:29:56"
     userid: "t863060h"
     username: "tryy catchh"</p>
  
  <p><strong>console.log(this.state)</strong></p>
  
  <pre><code>nName: "tryCatchh", …}
  addWorkspace: true
  divisionName: "dud"
  **divisions**: Array(0)//no data
  length: 0
  __proto__: Array(0)
  isDivisionViewable: true
  organizationId: "finalids"
  organizationName: "tryCatchh"
  role: "Admin"
  userId: "t863060h"
  workspacePP: false
  workspaces: [{…}]
  </code></pre>
  
  <p><strong>other funtction</strong></p>
  
  <pre><code>  showDivision=()=&gt;{
          console.log('dddd',this.state.divisions);
    }
  </code></pre>