Tried to update a state. Somehow the setState isn't working..
this is the function and state:
state = {
    security: {
      0: { id: "54321", name: "test1"}
      1: { id: "98765", name: "test2"}
              }
}
removeSecInState = (security) => () => {
        var temp = Object.assign({}, this.state.security)
        var temp1 = Object.values(temp)
        var index = temp1.findIndex(id => id.id ===  security.id) //getIndex
        delete temp[0]
        this.setState({security: temp},() =>  {
            console.log(temp, "inside");
            console.log(this.state.security, "inside1")
        })
    }
console.log(temp, "inside") =  
security: {
      1: { id: "98765", name: "test2"}
              }
console.log(this.state.security, "inside1") = 
security: {
      0: { id: "54321", name: "test1"}
      1: { id: "98765", name: "test2"}
              }
somehow, state is not updated to be the same with temp, always goes back to the previous state
 
    