Accepted answer

There are some issues in your code

  1. setState may be asynchronous, meaning state wont get updated immediately after setState is call. It is mentioned clearly in React docs:
  2. You should never directly modify the state inside componentDidMount It is also mentioned here: So I suggest modify the code as below

    componentDidMount() {
      this.getDeductionInfosList(data, function(response){
            group: [{ field: "DeductionTypeTitle" }]}, response.Result, true)
    createAppState(dataState, items collapseAll) {
      const dataResult = process( items, dataState);
      if (collapseAll) { => dataItem.expanded = false);
        dataResult: dataResult,
        dataState: dataState 


You have to transform the function to async and use await to the response.

async function getDeductionInfosList(data){ await GetRestrictionListService.getDeductionInfos(data, this.successGetDeductionInfos);}

Related Query

More Query from same tag